Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python (os.path.dirname(_文件__))在FreeBSD中不工作_Python_Django_Freebsd - Fatal编程技术网

Python (os.path.dirname(_文件__))在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

我想设置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/stores/images/
上面是我的系统,但在freeBSD上试用时,我得到:

/couponRestApiApp/stores/images/
但应该是这样

/home/vaibhav/coupon-rest-api/couponRestApi/couponRestApiApp/stores/images/

有人能告诉我出了什么问题吗…

您是否尝试过
os.path.dirname(os.path.abspath(_文件__))
?请看这里:这不是FreeBSD问题,而是如何调用脚本的问题<代码>\\\\\不保证是绝对路径。