os.getcwd() for a different drive in Windows

前端 未结 3 1573
天涯浪人
天涯浪人 2021-01-11 11:50

According to http://docs.python.org/library/os.path.html

\"On Windows, there is a current directory for each drive\"

This is giv

3条回答
  •  [愿得一人]
    2021-01-11 12:42

    I believe that the section you are reading that from is worded poorly. There is only one current working directory for your python session, and you get it from os.getcwd(). You can use os.chdir(r'F:\') to change directories to your F drive.

    The part that that quote is referencing is relating to the os.path.join method. It means that passing a first argument of 'C:' instead of r'C:\', you will get the incorrect path (namely C:path instead of C:\\path).

提交回复
热议问题