import os import inspect currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) # 获取当前文件所在的目录 rootdir = os.path.dirname(currentdir) # 去掉文件名,返回目录 os.sys.path.insert(0, rootdir) # 动态修改系统路径 把自己项目所在的地址放在sys.path 列表里面 # sys.path.insert(0,’模块的名称’) 添加相关的路径,但在退出python环境后自己添加的路径就会自动消失!



