Python (os.path.dirname(_文件__))在FreeBSD中不工作
我想设置images dir.的路径。在我的Django项目中…它工作正常,但当我在FreeBSD上运行脚本时,它不工作Python (os.path.dirname(_文件__))在FreeBSD中不工作,python,django,freebsd,Python,Django,Freebsd,我想设置images dir.的路径。在我的Django项目中…它工作正常,但当我在FreeBSD上运行脚本时,它不工作 import os imagesDirPath = (os.path.dirname(__file__)) + "/couponRestApiApp/stores/images/" print imagesDirPath output: /home/vaibhav/TRAC/coupon-rest-api/couponRestApi/couponRestApiApp/s
import os
imagesDirPath = (os.path.dirname(__file__)) + "/couponRestApiApp/stores/images/"
print imagesDirPath
output: /home/vaibhav/TRAC/coupon-rest-api/couponRestApi/couponRestApiApp/stores/images/
上面是我的系统,但在freeBSD上试用时,我得到:
/couponRestApiApp/stores/images/
但应该是这样
/home/vaibhav/coupon-rest-api/couponRestApi/couponRestApiApp/stores/images/
有人能告诉我出了什么问题吗…您是否尝试过
os.path.dirname(os.path.abspath(_文件__))
?请看这里:这不是FreeBSD问题,而是如何调用脚本的问题<代码>\\\\\不保证是绝对路径。