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+"..")  # 当前模块父目录的父目录

  

  

 

posted on 2018-09-03 11:57  陆小凤的笔记  阅读(82)  评论(0编辑  收藏  举报