Python 获取当前程序脚本文件的路径
目录
当前脚本/模块文件的路径,使用内置变量 __file__
。注意“file”两端是各两个下划线。
当前工作目录,使用 os.getcwd()
方法。
Python 3
For the directory of the script being run:
|
For the current working directory:
|
Python 2 and 3
For the directory of the script being run:
|
If you mean the current working directory:
|
相关内容
Python 当前工作目录的路径