您的位置:首页 > 编程语言 > Python开发

python中os.path.dirname(__file__)的使用

2013-03-26 15:01 393 查看
(1).当"print os.path.dirname(__file__)"所在脚本是以完整路径被运行的, 那么将输出该脚本所在的完整路径,比如:

             python d:/pythonSrc/test/test.py 

             那么将输出 d:/pythonSrc/test

(2).当"print os.path.dirname(__file__)"所在脚本是以相对路径被运行的, 那么将输出空目录,比如:

             python test.py

             那么将输出空字符串
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: