How to use “/” (directory separator) in both Linux and Windows in Python?

Use os.path.join().
Example: os.path.join(pathfile,"output","log.txt").

In your code that would be: rootTree.write(os.path.join(pathfile,"output","log.txt"))

Leave a Comment