标签: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