- 导入路径
import sys
sys.path
['',
'../',
'/Users/delron/.virtualenv/py3/bin',
'/Users/delron/.virtualenv/py3/lib/python36.zip',
'/Users/delron/.virtualenv/py3/lib/python3.6',
'/Users/delron/.virtualenv/py3/lib/python3.6/lib-dynload',
'/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
'/Users/delron/.virtualenv/py3/lib/python3.6/site-packages',
'/Users/delron/.virtualenv/py3/lib/python3.6/site-packages/IPython/extensions',
'/Users/delron/.ipython',
]
sys.path.append("../")
sys.path.insert(1, "../")
2.导入时 python解释器会维护一个包的副本 (缓存) 在内存中
- 让新模块生效的方式:
- 1. 重新启动
- 2. imp.reload()
3.导入同级或上级目录的文件可在模块前加上相对路径