标签:different dynamic function python between
def a(*args) # (dynamic) star symbol means this function could run with unlimited parameter.
args likes a tuple
e.g.
b = (1,2,3,4)
what‘s the different between a(b) and a(*b)
first one will put all b item as one item of *args.
second one will split b and put each one as a item of *args.
e.g. b="aaa" a(*b) # result is [a,a,a]
def a(**args) # double star will put argument like dict in memory.
e.g.
a(key1=‘value1‘,key2=‘value2‘...)
dic={‘k1‘:‘v1‘,‘k2‘,‘v2‘}
a(**dic)
almight argument
def f1(*args,**kwargs): #notice:Must place one-star before double-star, otherwise will get error
print(args)
print(kwargs)
Some tips about argument in python
标签:different dynamic function python between
原文地址:http://luluuy.blog.51cto.com/279347/1793339