8.5.1结合使用位置实参和任意数量实参
def hanshu(size,*cailiao):
print(“make a “+str(size)+”-inch pizza,with these toppings:”)
for i in cailiao:
print(i)
hanshu(12,‘yangcong’,‘qingjiao’,‘huotui’)
hanshu(16,‘liulian’,‘huotui’,‘haixian’,‘yangcong’)
8.5.2使用任意数量的关键字实参
def hanshu(xc1,xc2,**xc3):
zidian={}
zidian[‘key1firstname’]=xc1
zidian[‘key2lastname’]=xc2
for k,v in xc3.items():
zidian[k]=v
return zidian
celebrity=hanshu(‘sherlock’,‘homes’,location=‘london’,occupation=‘detective’)
print(celebrity)