python 部署时错误:文件找不到

os.path.abspath('.')  #得到的路径为整个工程目录的路径,不会得到详细的路径
 
 
os.path.split(os.path.realpath(__file__))[0] 
#会得到执行文件下的详细路径
如果在打开文件时,建议使用绝对路径。
path1FileMZ='%s%s' % (path1,'/mz.json') #民族的文件地址
路径进行拼接。不然部署服务器上时。会报错:不存在xx的文件

猜你喜欢

转载自blog.csdn.net/qq_28218253/article/details/80481250