我创建了两个文件:测试.py和test1234.py
测试.py包含:
import test1234
t = test1234.test()
test1234.py包含:
^{pr2}$当放入同一目录时,python test.py
运行时不会出错。在
但是,如果我创建一个目录test1234,并将test1234.py和一个空白的init.py,则python test.py
会给出错误:
AttributeError: 'module' object has no attribute 'test'
我需要为做什么测试.py能够在test1234.py中查看test
类?在
您必须通过包导入它,或者将它放入
__init__.py
。在相关问题 更多 >
编程相关推荐