*args和kwargs是什么意思?究竟是什么*args和**kwargs刻薄?根据Python文档,从表面上看,它以一组参数传递。def foo(hello, *args):
print hello for each in args:
print eachif __name__ == '__main__':
foo("LOVE", ["lol", "lololol"])打印出来:LOVE['lol', 'lololol']你如何有效地使用它们?
3 回答
慕容3067478
TA贡献1773条经验 获得超3个赞
class Super( object ): def __init__( self, this, that ): self.this = this self.that = thatclass Sub( Super ): def __init__( self, myStuff, *args, **kw ): super( Sub, self ).__init__( *args, **kw ) self.myStuff= myStuff x= Super( 2.7, 3.1 )y= Sub( "green", 7, 6 )
添加回答
举报
0/150
提交
取消