python------软件目录结构规范

一. 目录结构

www.cnblogs.com/alex3714/articles/5765046.html

print(__file__)  获得相对路径


import os
print(os.path.abspath(__file__)) 获取绝对路径


import os
import sys
print(os.path.abspath(__file__))
print(os.path.dirname(os.path.abspath(__file__)))
BASE = ( os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(BASE) #添加环境变量
import conf ,core


猜你喜欢

转载自www.cnblogs.com/bltstop/p/9557396.html