5
os.path.dirname(__ file__)は空を返します
.pyファイルが実行されている現在のディレクトリのパスを取得したい。 たとえばD:\test.py、コードを含む単純なファイル: import os print os.getcwd() print os.path.basename(__file__) print os.path.abspath(__file__) print os.path.dirname(__file__) 出力が次のようになるのは奇妙です: D:\ test.py D:\test.py EMPTY 私はから同じ結果を期待していますgetcwd()し、path.dirname()。 与えられたos.path.abspath = os.path.dirname + os.path.basename理由 os.path.dirname(__file__) 空を返しますか?
164
python