简体   繁体   English

Python TypeError:int() 最多接受 2 个参数(给出 3 个)

[英]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.

相关问题 Python — TypeError: format() 最多接受 2 个参数(给出 3 个) - Python — TypeError: format() takes at most 2 arguments (3 given) 读取用户输入会导致“ TypeError:int()最多接受2个参数(给定3个)” - Reading user input causes “TypeError: int() takes at most 2 arguments (3 given)” TypeError:write()最多接受5个参数(给定6个参数)Python Excel - TypeError: write() takes at most 5 arguments (6 given) Python Excel Python 数据集更新 - TypeError: update() 最多需要 2 个位置参数(给出 3 个) - Python dataset update - TypeError: update() takes at most 2 positional arguments (3 given) Python错误“ TypeError:sort()最多接受2个参数(给定3个)” - Python error “TypeError: sort() takes at most 2 arguments (3 given)” Python请求-TypeError:put()最多接受2个参数(给定4个) - Python requests - TypeError: put() takes at most 2 arguments (4 given) Python-子类TypeError:最多接受2个参数(给定3个),而应该接受3个 - Python - Subclass TypeError: takes at most 2 arguments (3 given) while it should take 3 TypeError:file()最多需要3个参数(给定4个参数) - TypeError: file() takes at most 3 arguments (4 given) TypeError:execute()最多接受3个参数(给定11个) - TypeError: execute() takes at most 3 arguments (11 given) 类型错误:UMat() 最多接受 2 个参数(给出 3 个) - TypeError: UMat() takes at most 2 arguments (3 given)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM