这个获取文件路径中所在的目录

1
2
3
4
5
6
7
In [1]: import os
 
In [2]: os.__file__
Out[2]: '/usr/lib/python2.7/os.pyc'
 
In [3]: os.path.dirname(os.__file__)
Out[3]: '/usr/lib/python2.7'

python os.path.dirname 是什么目录的更多相关文章

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

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

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

  4. python os.path.dirname() abspath()

    测试文件的名称 path_test.py 先确定文件目录 (my_flask3) python@ubuntu:~/Desktop/flask_news_pro$ python path_test.py ...

  5. python os.path.dirname()

    ----返回文件所在的路径 ----如果path变量直接是文件名则返回空

  6. Python模块详解以及import本质,获得文件当前路径os.path.abspath,获得文件的父目录os.path.dirname,放到系统变量的第一位sys.path.insert(0,x)

    模块介绍 1.定义: 模块:用来从逻辑上组织python代码(变量,函数,类,逻辑:实现一个功能),本质就是.py结尾的python文件(文件名:test.py,对应的模块名:test) 包:用来从逻 ...

  7. os.path.join合并 os.path.dirname返回上一级目录 os.path.exists(path) os.stat('path/filename')获取文件/目录信息

    import os str1 = "grsdgfd" str2 = "wddf" str3 = "gddgs" # print(str1 + ...

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

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

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

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

随机推荐

  1. 网摘 窗体的旋转效果 wpf

    <Window x:Class="simplewpf.chuantixx" Name="DW1"         xmlns="http://s ...

  2. asp.net下调用Matlab生成动态链接库

    对于这次论文项目,最后在写一篇关于工程的博客,那就是在asp.net下调用matlab生成的dll动态链接库.至今关于matlab,c/c++(opencv),c#(asp.net)我总共写了4篇配置 ...

  3. 整数分解 && 质因数分解

    输入整数(0-30)分解成所有整数之和.每四行换行一次. 一种方法是通过深度优先枚举出解.通过递归的方式来实现. #include <stdio.h> #include <strin ...

  4. php返回json数据中文显示的问题

    PHP5.4版本,已经给Json新增了一个选项: JSON_UNESCAPED_UNICODE.加上这个选项后,就不会自动把中文编码了. echo json_encode("厦门" ...

  5. easyUI validate函数【总结篇-部分转】

    以下是自己总结和修改别人的帖子和资源整理出来的一些常用验证函数,备用,交流. <body>邮箱验证:<input type="text" validtype=&q ...

  6. JavaScript学习笔记——对象基础

    javascript对象基础 一.名词解释: 1.基于对象 一切皆对象,以对象的概念来编程. 2.面向对象编程(oop Object oriented programming) A.对象 就是人们要研 ...

  7. python的简洁是shell无法代替的

    之前线上服务器分发配置都是用shell和expect脚本分发,脚本写了很长,上周换了ansible,现在自己用python写一个,就30行代码就可以实现需求,之前的shell写了快200行了,蛋疼,代 ...

  8. 正则匹配IP

    分析 IP地址的长度为32位,分为4段,每段8位,用十进制数字表示,每段数字范围为0~255( 2^8 ),段与段之间用英文句点“.”隔开.例如:某台计算机IP地址为10.11.44.100. IP地 ...

  9. PHP 学习

    http://www.w3school.com.cn/php/php_sessions.asp public static void chkacc() {Response.Redirect(" ...

  10. 使用BeanNameAutoProxyCreator实现spring的自动代理

    提到代理,我们可以使用ProxyBeanFactory,并配置proxyInterfaces,target和interceptorNames实现,但如果需要代理的bean很多,无疑会对spring配置 ...