python模块、包引入

# 方法一:
cur_root = os.path.split(os.path.abspath(__file__))[0]  # 当前模块绝对目录
# 方法二:
import inspect
cur_root = os.path.split(inspect.getfile(inspect.currentframe()))[0]  # 当前模块绝对目录

father_path=os.path.abspath(os.path.dirname(cur_root)+os.path.sep+".")  # 当前模块父目录
grader_father=os.path.abspath(os.path.dirname(cur_root)+os.path.sep+"..")  # 当前模块父目录的父目录

  

  

猜你喜欢

转载自www.cnblogs.com/lxfnote/p/9577763.html
今日推荐