码迷,mamicode.com
首页 > 其他好文 > 详细

模块间的调用

时间:2016-05-05 11:16:12      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:python 模块

1.自定义模块的调用

from backend.logic import handle

handle.home()


2.上层模块的调用

import os
import sys
print(__file__)
print(os.path.abspath(__file__))
print(os.path.dirname(os.path.abspath(__file__)))
base_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.append(base_dir)
print(sys.path)

$ python path.py 
path.py
/Users/guoxianqi/tmp/path.py
/Users/guoxianqi/tmp
[‘/Users/guoxianqi/tmp‘, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip‘, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7‘, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin‘, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac‘, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages‘, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python‘, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk‘, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old‘, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload‘, ‘/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC‘, ‘/Library/Python/2.7/site-packages‘, ‘/Users/guoxianqi/tmp‘]


本文出自 “AMY” 博客,请务必保留此出处http://amy2015.blog.51cto.com/11407620/1770247

模块间的调用

标签:python 模块

原文地址:http://amy2015.blog.51cto.com/11407620/1770247

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