[英]AttributeError: module '…' has no attribute '…'
我有文件:
生物群系
import animals
...
class woodsBiome(baseBiome):
# I do stuff
def __init__(self):
self.animals = animals.generateAnimals(5)
動物
def generateAnimals(quantity):
# I do stuff
當我在biomes.woodsBiome
上運行__init__
時,它在biomes.woodsBiome
animals.generateAnimals(5)
處失敗。 它給:
Traceback (most recent call last):
File "game.py", line 10, in <module>
import animals
File "/path/to/files/animals.py", line 4, in <module>
from game import die
File "/path/to/files/game.py", line 22, in <module>
areaMap = biomes.generateMap(xMax, yMax)
File "/path/to/files/biomes.py", line 85, in generateMap
biomeList = [woodsBiome(), desertBiome(), fieldBiome()]
File "path/to/files/biomes.py", line 41, in __init__
self.animals = animals.generateAnimals(5)
AttributeError: module 'animals' has no attribute 'generateAnimals'
我有一種明顯的失蹤感。 有人能指出我正確的方向嗎?
謝謝。
我還不能發表評論,所以這是一個問題。
在其中的代碼中,我注意到您的類在沒有self的情況下調用__init__()
。 這就是代碼中的樣子嗎? 是否將課程稱為
__init__(self)
改變什么?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.