No such file or directory when starting directory name with /

后端 未结 1 1804
忘掉有多难
忘掉有多难 2021-01-20 00:32

I am just confusing that when I apply:

os.listdir(\"HW-3/data_sets/\")

It works well! and list all the name of files under that directories

1条回答
  •  隐瞒了意图╮
    2021-01-20 01:23

    A leading slash in a path means an absolute path, or a path that starts at the root of your filesystem. No leading slash makes the path relative to your working directory (typically wherever you launched the script from).

    Because of this, the initial slash results in a path that is semantically different from no leading slash, so you should not expect the script to behave the same way for those two paths.

    0 讨论(0)
提交回复
热议问题