python调用不同目录下的方法
目录结构如下:
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()
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。