簡體   English   中英

導入Python類

[英]Importing Python classes

我有一個像這樣的文件夾結構:

-PCore
    |-__init__.py
    |-PFnTransform.py
    |-PEuler.py
    |-PPoint3.py
    |-...

在每個.py文件中,都有一個具有相同名稱的類。

我只想輸入以下內容:

from Core import PPoint3

但實際上我需要寫:

from Core.PPoint3 import PPoint3

當我打印類時,我得到的是<class 'PCore.PEuler.PEuler'>而不是<class 'PCore.PEuler'> (我想要的)

我需要在__init__.py文件中寫什么?

__init__.py文件中,您需要導入PPoint3類。

from PPoint3 import PPoint3

然后,您將能夠從PCore包中導入PPoint3類。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM