(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__) 命令行 参数没有绝对路径导致数据库找不到的更多相关文章

  1. python中的os.path.dirname与os.path.dirname(__file__)的用法

    python中的os.path.dirname的用法 os.path.dirname(path) 语法:os.path.dirname(path) 功能:去掉文件名,返回目录 如: print(os. ...

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

    在编程时,我们要获取当前文件所在的路径,以适合所有的工程,建立相对路径. python的os.path.dirname(__file__)非常好用,建议大家使用: import os FILE = o ...

  3. 转: Python中的os.path.dirname(__file__)

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

  4. Python os.path.dirname(__file__) os.path.join(str,str)

    Python os.path.dirname(__file__) Python os.path.join(str,str)   (1).当"print os.path.dirname(__f ...

  5. Python——os.path.dirname(__file__) 与 os.path.join(str,str)

    Python os.path.dirname(__file__) Python os.path.join(str,str)   (1).当"print os.path.dirname(__f ...

  6. Python os.path.dirname(__file__) 与 Python os.path.abspath(__file__) 与 os.system() 函数

    Python  os.path.dirname(__file__) 与 Python os.path.abspath(__file__) 的区别 os.path.abspath(__file__)返回 ...

  7. os.path.dirname(__file__)使用、Python os.path.abspath(__file__)使用

    python中的os.path.dirname(__file__)的使用 - CSDN博客https://blog.csdn.net/u011760056/article/details/469698 ...

  8. python中os.path 与sys.path

    看别人写的代码,会发现两个和路径设置有关的模块 os 和sys.我对这两个模块也不是特别了解.只是记录一下自己看到的,学到的. python 中我们会使用这两个模块和文件路径, 创建文件 之类的 操作 ...

  9. os.path.dirname(__file__)使用

    os.path.dirname(__file__)使用 该测试脚本所在的位置:D:\第1层\第2层\第3层\第4层\第5层\test11.py test11.py import os #该文件所在位置 ...

随机推荐

  1. 从Freelancer的热门Skill看看你应该学什么?

    以下数据是2012-1-31号数据. Websites, IT & Software: PHP (2402)HTML (1639)SEO(877)MySQL (836)Link Buildin ...

  2. Django Web项目代码规范参考

    Python:PEP8+GoogleStyle+DjangoSytlePEP8中文版:http://www.cnblogs.com/huazi/archive/2012/11/28/2792929.h ...

  3. python的统一编码规范

    请注意这一点:没有编码规范的代码没有阅读价值,也更谈不上复用. 目前业界比较流行的Python的编码规范目前主要有PEP8的编程.Google的编码风格.Python Guide和Pocoo Styl ...

  4. html居中定位

    <!DOCTYPE html PUBLIC "-//W3C//Ddiv XHTML 1.0 divansitional//EN" "http://www.w3.or ...

  5. FOF 全面科普贴(转载)

    看过那么多 FOF 科普贴,这份最全面!告转之~ 来自:https://xueqiu.com/7692591808/81852994 [ 导言 ] 看过那么多FOF科普贴,这份最全面! 昨天下午,青果 ...

  6. js实现地图打印功能

    注意:js对地图的打印功能在arcgis10.1中才有提供,所以如果要使用esri自带的地图打印功能,必须使用arcgis 10.1或更高版本的地图打印模板.(由于官网和arcgis desktop提 ...

  7. NopCommerce是什么(转自CNSD)

    NopCommerce是什么 nopCommerce--最好的免费购物车!nopCommerce是一个开源的解决方案.它是一个具有综合功能.对于新在线业务来说亦易于使用的解决方案,同时它也是一个功能强 ...

  8. Java CAS 原理分析

    1.简介 CAS 全称是 compare and swap,是一种用于在多线程环境下实现同步功能的机制(可以把 CAS 看做乐观锁).CAS 操作包含三个操作数 -- 内存位置.预期数值和新值.CAS ...

  9. struts2中的拦截器

    一  AOP思想: 面向切面编程的思想 AOP为Aspect Oriented Programming的缩写,意为:面向切面编程,通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术.AOP ...

  10. Activity,Window,View之间是什么关系?

    Activity在onCreate之前调用attach方法,在attach方法中会创建window对象.window对象创建时并没有创建 Decor对象对象.用户在Activity中调用setCont ...