问题描述
- 继承python内置的list,在创建实例时,提示参数个数不正确
-
- class namelist(list):
- def init(self,a_name,m1):
- list._init_([])
- self.name=a_name
- self.m=m1
- d=namelist('c','m')
报错:
Traceback (most recent call last):
File "", line 1, in
d=namelist('c','m')
TypeError: list() takes at most 1 argument (2 given)谢谢各位大神呀。
解决方案
d=namelist(['c','m'])
时间: 2024-11-03 12:33:30