Use os.path.join().Example: os.path.join(pathfile,"output","log.txt").
os.path.join()
os.path.join(pathfile,"output","log.txt")
In your code that would be: rootTree.write(os.path.join(pathfile,"output","log.txt"))
rootTree.write(os.path.join(pathfile,"output","log.txt"))
Use:
import osprint os.sep
to see how separator looks on a current OS.In your code you can use:
import ospath = os.path.join('folder_name', 'file_name')
You can use os.sep:
>>> import os>>> os.sep'/'