python的奇特操作

1.特殊赋值方法
>>> class Clist:
	def __init__(self,*args):#*args是参数个数可变的意思
		self.value=[x for x in args]
		self.count={}.fromkeys(range(len(self.value)),0)

		
>>> a = Clist(1,2,3)
>>> a.value
[1, 2, 3]
>>> a.count
{0: 0, 1: 0, 2: 0}

猜你喜欢

转载自blog.csdn.net/tommy1295/article/details/80781020