在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

相关文章:

  • 2021-05-31
  • 2021-10-21
  • 2022-12-23
  • 2021-04-16
  • 2021-06-05
  • 2021-05-03
  • 2021-09-17
  • 2021-07-30
猜你喜欢
  • 2021-12-22
  • 2022-01-07
  • 2022-01-07
  • 2022-01-07
  • 2021-10-30
  • 2021-11-19
相关资源
相似解决方案