1

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]: '/'
3
  • I'm curious: why do you want a final slash on the filename? Commented Nov 3, 2015 at 3:29
  • I am concatenating 2 os.path.joins Commented Nov 3, 2015 at 6:53
  • If you concatenate two path joins then your code shoud look like os.path.join(os.path.join('path', 'to', 'file'), os.path.join('second', 'path')) and everything will be fine. Commented Nov 3, 2015 at 8:02

2 Answers 2

2

Just add it yourself: os.path.join('path', 'to', 'file') + os.path.sep

Sign up to request clarification or add additional context in comments.

Comments

1

have your tried: os.path.join('path','to','file'+os.sep)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.