[英]Python TypeError: int() takes at most 2 arguments (3 given)
I am trying to write a simple hangman game in python but is getting this error.我正在尝试用 python 编写一个简单的刽子手游戏,但出现此错误。 Not sure where the error is coming from.不确定错误来自哪里。 I appreciate any help.我很感激任何帮助。 Thank you.谢谢你。
TypeError Traceback (most recent call last)
<ipython-input-1-323840294aea> in <module>
8 seconds = 60
9
---> 10 class engine(seconds):
11 import getpass
12 word=getpass.getpass("please enter a secret word")
TypeError: int() takes at most 2 arguments (3 given)
Code:代码:
You have a global int
variable named seconds
that you are attempting to derive your classes from.您有一个名为seconds
的全局int
变量,您正试图从中派生类。 I suspect you intended them to be functions, which requires def
not class
, eg:我怀疑您打算将它们作为函数,这需要def
而不是class
,例如:
def engine(seconds):
However, you also have multiple classes/functions named the same thing so you will also need to resolve that.但是,您还有多个类/函数命名为相同的事物,因此您还需要解决这个问题。
You don't need to use classes for that.您不需要为此使用类。 Instead, use def
keyword and define the function with the seconds
parameter.相反,使用def
关键字并使用seconds
参数定义函数。 You are trying to derive a class from an integer.您正试图从一个整数派生一个类。
Also, you have 2 engine
"classes".此外,您有 2 个engine
“类”。 The second definition will overwrite the first one.第二个定义将覆盖第一个定义。 So you will have to change that.所以你必须改变它。
def engine(seconds)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.