(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__)的更多相关文章

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

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

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

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

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

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

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

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

  5. 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__)返回 ...

  6. 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 ...

  7. 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 ...

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

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

  9. os.path.dirname(__file__)

    os.path.dirname(__file__) 返回脚本的路径 描述: 必须实际存在的.py文件,如果直接在命令行执行,则会引发异常NameError: name 'file' is not de ...

随机推荐

  1. go语言基础之二维数组

    1.二维数组 示例: package main //必须有个main包 import "fmt" func main() { //有多少个[]就是多少维 //有多少个[]就用多少个 ...

  2. C# WinForm开发系列 - GDI+【转】

    http://blog.csdn.net/blue_sky6/article/details/53811435?locationNum=6&fps=1 C# WinForm开发系列 - GDI ...

  3. POJ 1651 Multiplication Puzzle (区间DP)

    Description The multiplication puzzle is played with a row of cards, each containing a single positi ...

  4. 县级以上联动js实现无需数据库的行政区域下拉控件

    代码共享url: http://code.google.com/p/region-select-js/ 数据已经更新到中国统计局网站中的2012年的那批数据(制作后未核对); 下拉使用div模拟实现. ...

  5. Gh0st整理资料1

    题首 Gh0st是一款开源的远程控制软件.界面友好,性能高效.网上流传很多版本,比如红狼,饭客,败笔,大灰狼版本以及多如牛毛的个人修改的如外星人,Drat等个人修改版本.但内核都是基于Gh0st3.6 ...

  6. Cognos事件工作室Event Studio开发步骤

    Cognos本身是很强大的,只是很多人的思维只是局限在数据-模型-展示的层面上,下面我们就来介绍一下Cognos中稍微有些冷门的一个组件事件工作室(IBM Cognos Event Studio),概 ...

  7. XGBoost:在Python中使用XGBoost

    原文:http://blog.csdn.net/zc02051126/article/details/46771793 在Python中使用XGBoost 下面将介绍XGBoost的Python模块, ...

  8. Javascript游戏,街头霸王

    在线演示 本地下载 街头霸王,有没有记起点什么?我想起了那个有颗大槐树的老院子,还有一台小霸王和一个儿时的伙伴.

  9. Linux集群监控工具简介:Ganglia和Nagios

    11年时候,曾经对 Ganglia 和 Nagios有一定接触,这是两个用于监视数据中心的工具.这两个工具被大量用于高性能计算(HPC)环境中,但是它们对于其他环境也具有很大的吸引力(例如云.呈现集群 ...

  10. 【.NET中AOP的实现方案】静态代理

    Spring AOP 应该是比较出名的了,今天说的是C#里的AOP,C#的AOP实现的方式有很多种,现在就先介绍静态代理的实现方案: 模拟场景:我们在删除用户,或者更新用户的时候进行数据原始备份,这样 ...