How to get 'path/to/file/'
This is missing the last '/'
In [2]: os.path.join('path', 'to', 'file')
Out[2]: 'path/to/file'
This does not help:
In [3]: os.path.join('path', 'to', 'file', '/')
Out[3]: '/'
idjaw
26.8k10 gold badges68 silver badges84 bronze badges
2 Answers 2
Just add it yourself: os.path.join('path', 'to', 'file') + os.path.sep
answered Nov 3, 2015 at 2:07
Kevin
76.5k13 gold badges141 silver badges168 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
have your tried: os.path.join('path','to','file'+os.sep)
answered Nov 3, 2015 at 2:10
smertrios
3,5051 gold badge16 silver badges9 bronze badges
Comments
lang-py
os.path.join(os.path.join('path', 'to', 'file'), os.path.join('second', 'path'))and everything will be fine.