在python中,这两个是python中的可变参数,*arg表示任意多个无名参数,类型为tuple;**kwargs表示关键字参数,为dict. # *允许你传入0个或任意个参数,这些可变参数在函数调用时自动组装为一个tuple. def f(a,*args): print(args) f(1,2,3,4) def calc(*numbers): sum = 0 for n in numbers: sum = sum + n * n print(sum) calc(1,2,3,4) # **,关…
Python中__repr__和__str__区别 看下面的例子就明白了 class Test(object): def __init__(self, value='hello, world!'): self.data = value >>> t = Test() >>> t <__main__.Test at 0x7fa91c307190> >>> print t <__main__.Test object at 0x7fa91c3…