码迷,mamicode.com
首页 > 编程语言 > 详细

python模块、包引入

时间:2018-09-03 13:39:46      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:file   import   pre   引入   fat   pat   nbsp   name   bsp   

 

 

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

  

  

 

python模块、包引入

标签:file   import   pre   引入   fat   pat   nbsp   name   bsp   

原文地址:https://www.cnblogs.com/lxfnote/p/9577763.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!