获取文件路径' /'

时间:2015-11-03 02:06:19

标签: python os.path

如何获得&/ 39; path / to / file /'

这是最后的' /'

In [2]: os.path.join('path', 'to', 'file')
Out[2]: 'path/to/file'

这没有用:

In [3]: os.path.join('path', 'to', 'file', '/')
Out[3]: '/'

2 个答案:

答案 0 :(得分:2)

只需自己添加:os.path.join('path', 'to', 'file') + os.path.sep

答案 1 :(得分:1)

尝试过:os.path.join('path','to','file'+ os.sep)