which one should I use: os.sep or os.path.sep?

后端 未结 4 1524
心在旅途
心在旅途 2020-12-13 16:48

They are same, but which one should I use?

http://docs.python.org/library/os.html:

os.sep

The character used by t

4条回答
  •  余生分开走
    2020-12-13 17:47

    The following examples could highlight the differences between os.path.join and os.path.sep.join.

    import os os.path.join("output", "images", "saved") 'output/images/saved' os.path.sep.join(["output", "images", "saved"]) 'output/images/saved'

    I guess the os.path.sep.join is more robust and can be used w/o modifications for any os.

提交回复
热议问题