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)的更多相关文章
- 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(__file__)的使用
在编程时,我们要获取当前文件所在的路径,以适合所有的工程,建立相对路径. python的os.path.dirname(__file__)非常好用,建议大家使用: import os FILE = o ...
- python中os.path.dirname(__file__) 命令行 参数没有绝对路径导致数据库找不到
(1).当"print os.path.dirname(__file__)"所在脚本是以完整路径被运行的, 那么将输出该脚本所在的完整路径,比如: python d:/python ...
- 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与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 #该文件所在位置 ...
- 第十八篇 模块与包--time&random模块&模块导入import(os.path.dirname(os.path.abspath(__file__)))
模块 在Python中, 一个.py文件就称为一个模块. 使用模块的好处: 1. 最大的好处就是大大提高了代码的可维护性 2. 编写代码不必从零开始.一个模块编写完毕,就可以被其他地方引用.在写其他程 ...
随机推荐
- Additinal Dependencies和#pragma comment(lib,"*.lib")的分析
网上.一些书上也写道,这两种方式作用一样.其实仔细分析,它们两者还是有非常大的差异的. Additinal Dependencies和#pragma comment(lib,"*.lib& ...
- 解决 Package test is missing dependencies for the following libraries: libcrypto.so.1.0.0
根据项目要求需要用到openssl这个库,看了看编译环境幸好本身就集成了该库.但在编译openssl的功能时,碰到缺少类库的错误. Package test is missing dependenci ...
- hadoop跑第一个实例过程
第一次跑hadoop实例,中间经过了不少弯路,特此记录下来: 第一步:建立一个maven过程,pom.xml文件:(打包为jar包) <dependency> <groupId> ...
- p12转pem公钥私钥
cer格式证书生成p12文件,前面写了有一篇了. 这里是从p12文件导出公钥和私钥 //1.生成1.key文件 openssl pkcs12 -in apple_payment.p12 -nocert ...
- Race to 1 UVA - 11762 (记忆dp概率)
#include <iostream> #include <cstdio> #include <sstream> #include <cstring> ...
- 创建Qt项目
创建Qt项目 1 创建Qt项目 2.1 使用向导创建 打开Qt Creator 界面选择 New Project或者选择菜单栏 [文件]-[新建文件或项目]菜单项 弹出New Project对 ...
- 在ls /bin搜索的结果中找到以m开头的
ls /bin | grep ^m 在ls /bin搜索的结果中找到以m开头的 find [目录] [条件] [动作] find - name "dsa" name 指定名字 ty ...
- bzoj3173: [Tjoi2013]最长上升子序列(fhqtreap)
这题用fhqtreap可以在线. fhqtreap上维护以i结尾的最长上升子序列,数字按从小到大加入, 因为前面的数与新加入的数无关, 后面的数比新加入的数小, 所以新加入的数对原序列其他数的值没有影 ...
- Java之JNI的介绍与应用20170622
/*************************************************************************************************** ...
- Linux之进程通信20160720
好久没更新了,今天主要说一下Linux的进程通信,后续Linux方面的更新应该会变缓,因为最近在看Java和安卓方面的知识,后续会根据学习成果不断分享更新Java和安卓的方面的知识~ Linux进程通 ...