Why use os.path.join over string concatenation?

后端 未结 3 2042
借酒劲吻你
借酒劲吻你 2020-11-27 16:00

I\'m not able to see the bigger picture here I think; but basically I have no idea why you would use os.path.join instead of just normal string concatenation?

3条回答
  •  难免孤独
    2020-11-27 16:25

    It is OS-independent. If you hardcode your paths as C:\Whatever they will only work on Windows. If you hardcode them with the Unix standard "/" they will only work on Unix. os.path.join detects the operating system it is running under and joins the paths using the correct symbol.

提交回复
热议问题