python中os.path.dirname(__file__) 命令行 参数没有绝对路径导致数据库找不到

时间:2014-07-26 01:09:56   收藏:0   阅读:232

   (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 /Users/wuchuanbo/PycharmProjects/wehome_wap/whserver.py --logging=debug  --port=8080

python中os.path.dirname(__file__) 命令行 参数没有绝对路径导致数据库找不到,布布扣,bubuko.com

评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!