目录结构如下:


atm.py调用main.py里的函数:

importosimportsys#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)#将该路径追加到环境变量fromconfimportsettingfromcoreimportmainmain.login()