Python——os.path.dirname(__file__) 与 os.path.join(str,str)
认识下os.path.dirname(__file__)
获取路径名:os.path.dirname()
获取文件所在目录的完整路径:os.path.dirname(__file__)
在django项目中的settings.py中还可以进行如下的配置:
如配置数据库:
1 import os
2 DATABASE_ENGINE='sqlite3'
3 DATABASE_NAME=os.path.join(os.path.dirname(__file__),'myAPP/mydata.db')
其中 os.path.dirname(__file__)函数用于取出settings.py所在文件夹的位置,在用os.path.join()函数将该位置和后面指定的'myAPP/mydata.db' 字符串连接一起,实现sqlite3数据库文件mydata.db具体存放的位置。
Python——os.path.dirname(__file__) 与 os.path.join(str,str)的更多相关文章
- os.path.dirname(__file__)和os.path.abspath(__file__)区别
- python中os.path.dirname(__file__) 命令行 参数没有绝对路径导致数据库找不到
(1).当"print os.path.dirname(__file__)"所在脚本是以完整路径被运行的, 那么将输出该脚本所在的完整路径,比如: python d:/python ...
- python中的os.path.dirname(__file__)的使用
在编程时,我们要获取当前文件所在的路径,以适合所有的工程,建立相对路径. python的os.path.dirname(__file__)非常好用,建议大家使用: import os FILE = o ...
- 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__)返回 ...
- 转: Python中的os.path.dirname(__file__)
(1).当"print os.path.dirname(__file__)"所在脚本是以完整路径被运行的, 那么将输出该脚本所在的完整路径,比如: ...
- 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 ...
- python中的os.path.dirname与os.path.dirname(__file__)的用法
python中的os.path.dirname的用法 os.path.dirname(path) 语法:os.path.dirname(path) 功能:去掉文件名,返回目录 如: print(os. ...
- os.path.dirname(__file__)使用、Python os.path.abspath(__file__)使用
python中的os.path.dirname(__file__)的使用 - CSDN博客https://blog.csdn.net/u011760056/article/details/469698 ...
- os.path.dirname(__file__)使用
os.path.dirname(__file__)使用 该测试脚本所在的位置:D:\第1层\第2层\第3层\第4层\第5层\test11.py test11.py import os #该文件所在位置 ...
随机推荐
- 自定义View Draw过程(4)
目录 目录 1. 知识基础 具体请看我写的另外一篇文章:自定义View基础 - 最易懂的自定义View原理系列 2. draw过程作用 绘制View视图 3. draw过程详解 同measure.la ...
- checkbox选中 解决兼容问题
jquery 1.9 checkbox 是否选中 if($("#chk_selectedall").prop('checked')) checkbox 选中 $("#ch ...
- 第二部分:Spring中配置mongodb
一.需要引用的jar包 1.spring-data-mongodb-1.9.4.RELEASE.jar 2.spring-data-commons-1.12.11.RELEASE.jar 3.mong ...
- poj 2546(两圆公共面积)
Circular Area Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5682 Accepted: 2225 Des ...
- 【原创】Talend ETL Job日志框架——基于P&G项目的一些思考和优化
一.背景 接触talend也挺长一段时间了,在P&G项目中每天都是使用它开发job,做ETL,也看了前辈开发的很多ETL Job,学到不少.也接触了TAC(talend administrat ...
- yii2实现WebService 使用 SoapDiscovery
结合SoapDiscovery实现简单的WebService服务 1 修改php.ini文件 php_soap.dll extension=php_soap.dll 2 WebService 实现主要 ...
- ASP.NET Code First Update-Database
问题描述: 复制了一个模块化的MVC5的项目,模块化的解释是说不同功能的模块分开来放的. 明确每个模块都是做什么工作的. 首先最基本的,就是根据Apps.Models模块来创建数据库了. 做法是卸载A ...
- NOIP2018提高组模拟题(二)
咒语(curse) Description 亮亮梦到自己来到了魔法城堡,但一扇巨大的石门阻拦了他通向城堡内的路. 正当他沮丧之际,突然发现门上有一处机关,机关上有一张很长的纸条. 亮亮拿起纸条的一端, ...
- ST表【p1311】 选择客栈
题目描述 丽江河边有 n 家很有特色的客栈,客栈按照其位置顺序从 1 到 n 编号.每家客栈都按照某一种色调进行装饰(总共 k 种,用整数 0~k-1 表示),且每家客栈都设有一家咖啡店,每家咖啡店均 ...
- implements
implements 是实现某个接口的意思. 如果某个类 后面使用 implements,并指定了相应的接口,那在该类下面就需要实现相应接口的方法. 比如:接口interface java.lang. ...