Python站点包导入

时间:2017-03-22 10:18:32

标签: python python-2.7 import

我在环境中有一个site-packages文件夹。这包含示例性站点包“测试”。 现在在这个“\ lib \ site-package \ test”中有两个文件。 init .py和testwrapper.py。

init .py:

import testwrapper
Testclass = testwrapper.Testclass()

当我在IDE中运行 init .py时,它会完美地启动此“Testclass”,我可以将其作为示例Testclass.exampleFunction()使用。

当我现在运行python控制台并输入import test时,它会找到site-package并导入它。但我无法在IDE中使用Testclass.exampleFunction(),因为Testclass未知。如果我手动输入 init .py中的代码,我可以使用它,因此在控制台中:

import test

import testwrapper
Testclass = testwrapper.Testclass()
Testclass.exampleFunction()

这在控制台中运行良好。但据我了解,如果我使用import test导入网站包, init .py将自动加载并启动? 感谢您帮助理解家伙。

0 个答案:

没有答案
相关问题