目录结构以下:python
atm.py调用main.py里的函数:微信
import os import sys # print(__file__) #获取当前文件相对路径 #print(os.path.abspath(__file__)) #经过相对路径获取绝对路径 #print(os.path.dirname(os.path.abspath(__file__))) #获取当前文件父目录 DIR_BASE = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # print(DIR_BASE) sys.path.append(DIR_BASE) #将该路径追加到环境变量 from conf import setting from core import main main.login()