(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. JavaScript中对象数组,如何给对象添加一个新属性

    var a =[{name: 'Tom',age:20},{name: 'Tom2',age:22}] 现在给a数组中的第一个对象添加性别属性 a[0]['gender']='women' a[0][ ...

  2. GPU计算的十大质疑—GPU计算再思考

    http://blog.csdn.NET/babyfacer/article/details/6902985 原文链接:http://www.hpcwire.com/hpcwire/2011-06-0 ...

  3. 6 Tools To Jump Start Your Video Content Marketing

    http://www.forbes.com/sites/drewhendricks/2014/10/16/6-tools-to-jump-start-your-video-content-market ...

  4. Java在线考试系统(含源码)

    本文demo下载和视频教学观看地址:http://www.wisdomdd.cn/Wisdom/resource/articleDetail.htm?resourceId=1076 本实例介绍了在线考 ...

  5. 深度学习之 TensorFlow(四):卷积神经网络

    基础概念: 卷积神经网络(CNN):属于人工神经网络的一种,它的权值共享的网络结构显著降低了模型的复杂度,减少了权值的数量.卷积神经网络不像传统的识别算法一样,需要对数据进行特征提取和数据重建,可以直 ...

  6. LeetCode_图像渲染

    题目: 有一幅以二维整数数组表示的图画,每一个整数表示该图画的像素值大小,数值在 0 到 65535 之间. 给你一个坐标 (sr, sc) 表示图像渲染开始的像素值(行 ,列)和一个新的颜色值 ne ...

  7. 【读英文文档】Whetting Your Appetite(刺激你的食欲)

    如果你有很多工作是通过计算机来完成的,那么你一定希望其中的很多事情能够自动地实现.比方说,你希望在文本文件中实现查找和替换的功能,以某一种机制实现照片的重命名以及重新排序的功能,一个小型的数据库甚至是 ...

  8. 团队项目第二阶段个人进展——Day8

    一.昨天工作总结 冲刺第八天,完成了发布页面数据与服务器数据的交互,基本实现了发布功能 二.遇到的问题 存在bug,有时候图片发布不了 三.今日工作规划 优化图片的上传机制,实现选择图片后就立即上传

  9. ubuntu宽带连接

    1.打开终端:    输入:sudo pppoeconf    根据提示输入宽带用户名和密码,若提示Plugin rp-pppoe.so loaded.则已连接成功.2.手动开启/断开连接:    p ...

  10. PHP后端之验证码

    PHP后端之验证码 前言: 打算写一些实际开发中遇到的东西.我这个人记性不好,觉得记下来,以后就算想找,也能找得到. PHP,可能很长一段时间都不会使用了.所以还是留一些记录. 另外还有一些服务器架设 ...