我的文件夹结构如下:
-PCore
|-__init__.py
|-PFnTransform.py
|-PEuler.py
|-PPoint3.py
|-...
在每个 .py 文件中都有一个同名的类。
我只想通过写入导入:
from Core import PPoint3
但实际上我需要写:
from Core.PPoint3 import PPoint3
当我打印类(class)时,我得到 <class 'PCore.PEuler.PEuler'>
而不是<class 'PCore.PEuler'>
(我想要什么)
我需要在__init__.py
中写什么文件?
最佳答案
在__init__.py
文件中,您需要导入PPoint3
类。
from PPoint3 import PPoint3
然后,您将能够从 PCore
包中导入 PPoint3
类。
关于python - 导入 Python 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20428156/