Unix paths that work for any platform in Python?

后端 未结 7 2032
迷失自我
迷失自我 2021-01-04 17:35

Can all paths in a Python program use \"..\" (for the parent directory) and / (for separating path components), and still work whatever the platform?

On one

7条回答
  •  时光说笑
    2021-01-04 18:06

    As others have said, a forward slash will work in all cases, but you're better off creating a list of path segments and os.path.join()-ing them.

提交回复
热议问题