码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2015-07-29 15:35:36      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:

(1).当"print os.path.dirname(__file__)"所在脚本是以完整路径被运行的, 那么将输出该脚本所在的完整路径,比如:

             python d:/pythonSrc/test/test.py

             那么将输出 d:/pythonSrc/test

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

             python test.py

             那么将输出空字符串

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

标签:

原文地址:http://www.cnblogs.com/liuYY1989/p/4685758.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!