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

Python模块调用时的路径查找

时间:2017-09-12 22:01:24      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:end   sys   font   span   app   port   rom   nbsp   time   

 

import sys 
import os 

base_dir = os.path.dirname(os.path.abspath(__file__))

sys.path.append(base_dir) 
os.path.abspath(__file__)  确认*.py的绝对路径
os.path.dirname(os.path.abspath(__file__)) 返回*.py的上一级文件路径

sys.path.append(base_dir) 添加搜索路径


 

Python模块调用时的路径查找

标签:end   sys   font   span   app   port   rom   nbsp   time   

原文地址:http://www.cnblogs.com/ystwyfe/p/7512242.html

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