标签:常见 c语言 python 前言 lan 语言 first 定时 pre
def args_test(param1,*args):
print "first param is:",param1
index = 1
for value in args:
print "the "+str(index)+" is:"+str(value)
index += 1
def kwargs_test(param1,**kwargs):
print "the first param is: ",param1
for key in kwargs:
print "the key is: %s, and the value is: %s" %(key,kwargs[key])
if __name__ == "__main__":
args_test('ha',1,'a','b','d','test')
kwargs_test('hi,kwargs',tom = 30,lilei = 28,hamei = 29)
程序结果:
first param is: ha
the 1 is:1
the 2 is:a
the 3 is:b
the 4 is:d
the 5 is:test
the first param is: hi,kwargs
the key is: lilei, and the value is: 28
the key is: hamei, and the value is: 29
the key is: tom, and the value is: 30
标签:常见 c语言 python 前言 lan 语言 first 定时 pre
原文地址:http://www.cnblogs.com/codeblock/p/python_args_kwargs.html