在os 包下,给出

import os ,os.path.abspath(__file__)获取当前文件的相对路径,os.path.dirname 获取当前文件所在的文件夹目录

print(os.path.dirname(os.path.abspath(__file__)))

 

然后添加系统环境变量,sys.path.append(文件夹路径),当然在使用前先导入import sys

 

from  文件夹 import 包下的py文件模块 i

相关文章: