【发布时间】:2019-12-30 17:51:16
【问题描述】:
这是我在主文件中的代码:
from File2.Test import test
test()
这是包含该类的文件的代码:
class Test:
def test(self):
print('Test')
如您所见,我不只是想导入类,我想从类中导入一些东西。当我尝试上面的语法时,我得到了这个错误:ModuleNotFoundError: No module named 'File2.Test'; 'File2' is not a package。如果无论如何要从 File2 导入 test(),请告诉我。任何帮助将不胜感激!
【问题讨论】:
标签: python-3.x file class import