1.傳遞任意數量的關鍵字實參:符號爲**
def build_porfile(first,last,**user_info):
profile={}
profile[‘first_name’]=first
profile[‘lase_name’]=last
for key,value in user_info.items():
profile[key]=value
return profile
user_info=build_porfile(‘albert’,‘einstein’,location=‘prinecton’,field=‘physics’)
print(user_info)
2.傳遞任意數量的實參:符號爲*
#def sandwitch(*ingredents):
print(“The ingredient of the sandwitch including”)
for ingredent in ingredents:
print(ingredent)
sandwitch(‘cabbage’,‘prock’,‘beef’)
sandwitch(‘mutton’,‘fish’)