目录间文件相互调用

#!/usr/bin/env python
print('welcome to my atm')
print(__file__)#相对路径
import os
import sys
print(os.path.abspath(__file__))#绝对路径
print(os.path.dirname(os.path.abspath(__file__)))#上级目录
print(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))#上级目录
BASE_DIR=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(BASE_DIR)#加入环境变量
import conf,core
from conf import setting
from core import main
main.login()

猜你喜欢

转载自www.cnblogs.com/rongye/p/9936835.html