目錄結構以下: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()