(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. Ubuntu16.04部署phantomjs的一个问题

    首先phantomjs是作为pyspider的一个外部依赖组件部署的. apt安装完出现问题: QXcbConnection: Could not connect to display Phantom ...

  2. How To Install and Use Redis

    https://www.digitalocean.com/community/tutorials/how-to-install-and-use-Redis About Redis redis, dev ...

  3. Opencv3.1+python2.7的CentOS7安装

    http://blog.csdn.NET/daunxx/article/details/50506625 转载注释:有些包名和系统包名并不匹配,yum install 找不到的时候,可以yum sea ...

  4. RocketMQ源码 — 八、 RocketMQ消息重试

    RocketMQ的消息重试包含了producer发送消息的重试和consumer消息消费的重试. producer发送消息重试 producer在发送消息的时候如果发送失败了,RocketMQ会自动重 ...

  5. All is Over

    Noip2017结束,AFO.WC2017上神犇们唱的膜你抄   就是退役的背景音乐了 不管以后何去何从,Oier的生涯对我来说已经终了,找个日子好好回忆一下这么多年的Oi时光,然后写篇博文祭奠 自此 ...

  6. 面试(三)---volatile

    一.前言       最近去成都玩了一圈,整体感觉还不错,辞职以后工作找的也很顺利,随着年龄增加自己也考虑定居和个人长期发展的问题,反正乱七八糟的事,总之需要好好屡屡思路,不能那么着急下定论,当然我对 ...

  7. python 中的csv读写

    1.首先 import csv 2.读一个csv文件 data = open(filename) lines = csv.reader(data)  #reader 函数和 dirtreader函数的 ...

  8. react native 1跳2 2跳3 3跳4 4pop回2

    网上有介绍导航的很多了 就不一一说了   直接说一个小功能 popToRoute pop回指定页面  第一次写 组织能力不是特别好 直接贴代码 例如 我们有四个页面  从第四个pop到第二个页面  先 ...

  9. linux下错误的捕获:errno(errno.h)和strerror(string.h)的使用

    参考:http://blog.csdn.net/starstar1992/article/details/52756387 linux下错误的捕获:errno和strerror的使用 经常在调用lin ...

  10. Linux上配置使用iSCSI详细说明

    本文详细介绍iSCSI相关的内容,以及在Linux上如何实现iSCSI. 第1章 iSCSI简介 1.1 scsi和iscsi 传统的SCSI技术是存储设备最基本的标准协议,但通常需要设备互相靠近并用 ...