1. 导入包的问题
Posted 不要被骄傲遮蔽了双眼
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了1. 导入包的问题相关的知识,希望对你有一定的参考价值。
1.import导入包的路径
In [4]: import sys In [5]: sys.path Out[5]: [\'\', \'/usr/bin\', \'/usr/lib/python35.zip\', \'/usr/lib/python3.5\', \'/usr/lib/python3.5/plat-x86_64-linux-gnu\', \'/usr/lib/python3.5/lib-dynload\', \'/usr/local/lib/python3.5/dist-packages\', \'/usr/lib/python3/dist-packages\', \'/usr/lib/python3/dist-packages/IPython/extensions\', \'/home/python/.ipython\']
### 添加路径 In [6]: sys.path.append(\'/home\') In [7]: sys.path Out[7]: [\'\', \'/usr/bin\', \'/usr/lib/python35.zip\', \'/usr/lib/python3.5\', \'/usr/lib/python3.5/plat-x86_64-linux-gnu\', \'/usr/lib/python3.5/lib-dynload\', \'/usr/local/lib/python3.5/dist-packages\', \'/usr/lib/python3/dist-packages\', \'/usr/lib/python3/dist-packages/IPython/extensions\', \'/home/python/.ipython\', \'/home\']
2.reload重新导入模块
In [1]: import test1 In [2]: test1.test1() ----1-- In [3]: from imp import * #reload在imp包内 In [4]: reload(test1) Out[4]: <module \'test1\' from \'/home/python/02-就业班/01-python高级-1/test1.py\'> In [5]: test1.test1() ----1-- ----2--
3.模块循环导入
## 模块a,b互相调用 ### cat a.py from b import b1 def a1(): print(\'----a1\') b1() a1() ### b.py from a import a1 def b1(): print(\'---b1\') a1() b1()
以上是关于1. 导入包的问题的主要内容,如果未能解决你的问题,请参考以下文章