Python文本冒险游戏中的参数错误
尝试使用Python中的游戏引擎进行文本冒险。不管怎样,我一直收到这个错误消息Python文本冒险游戏中的参数错误,python,class,import,init,Python,Class,Import,Init,尝试使用Python中的游戏引擎进行文本冒险。不管怎样,我一直收到这个错误消息TypeError:module.\uuuu init\uuuuu()最多接受2个参数(给定3个) 这是我的密码: from engine import game from engine import event from engine import place class TextAdventureGame(game): def __init__(self): super(TextAdve
TypeError:module.\uuuu init\uuuuu()最多接受2个参数(给定3个)
这是我的密码:
from engine import game
from engine import event
from engine import place
class TextAdventureGame(game):
def __init__(self):
super(TextAdventureGame, self).__init__()
self.introduction = ('''Welcome to Can You Escape text adventure game.
You wake up in a dark room and you have no idea where you are.''')
为什么会发生这种错误
类文本冒险游戏(游戏):
TypeError:module.\uuuu init\uuuuuu()最多接受2个参数(给定3个)
这个问题的提出方式很难回答,但从外观上看,我想说错误在这里:
class TextAdventureGame(game):
它说的是
模块。
,而不是TextAdventureGame。
,这让我觉得game
是一个以奇怪的方式使用的模块。但是,如果不知道您的代码、什么是game
,或者没有看到堆栈跟踪,我们真的不能做更多。game
是一个模块。您应该使用类作为基类
>>> import os
>>> class C(os):
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: module.__init__() takes at most 2 arguments (3 given)
导入操作系统
>>>C类(操作系统):
... 通过
...
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
TypeError:module.\uuuuu init\uuuuuu()最多接受2个参数(给定3个)
你如何实例化你的类?考虑把问题的标题改成反映你具体问题的东西。1:这是你的全部代码吗?2:如果删除
super(TextAdventureGame,self)。\uuu init\uuuu()
,是否会出现相同的错误?