我尝试在这里创建一个玩具类
class Toy:
def __init__(self,name,ID,price,age):
self.__ToyName = name
self.__ToyID = ID
self.__Price = price
self.__MinimumAge = int(age)
##some methods here
当我尝试制作子类计算机游戏时,我需要提出 7 个参数(其中 5 个来自玩具类)来实例化计算机游戏类,并且它显示“太多争论 (7/5)”
class ComputerGame(Toy):
def __init__(self,name,ID,price,age,catogory,console):
Toy.__init__(self,name,ID,price,age)
self.__Catogory = catogory
self.__Console = console
遇到这种情况我该怎么办?
最佳答案
您需要了解有关super
的更多信息
class ComputerGame(Toy):
def __init__(self, name, ID, price, age, catogory, console):
super(ComputerGame, self).__init__(name, ID, price, age)
self.__Catogory = catogory
self.__Console = console
关于python - 如何处理python 3中的错误 "too many arguments",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48457356/