python 中keyword argument和non-key argument
阿新 • • 發佈:2019-02-15
python
def var_args_func(formal1, formal2=’xyz’,*vark,**varnk):
print “formal argument 1 “,formal1
print “formal argument 2 “,formal2
for eachk in vark:
print’another keyword argument: ‘, eachk
for eachnk in varnk:
print’another non-keyword argument %s=%s’ \
%(eachnk,str(varnk[eachnk]))
var_args_func(‘city’,30,’USA’,’2000’,reg=30,que=42)
formal argument 1 city
formal argument 2 30
another keyword argument: USA
another keyword argument: 2000
another non-keyword argument que=42
another non-keyword argument reg=30