#函数
#使用任意数量的关键词参数
def my_profile(first, last, **user_info):
profile = {}
profile[“first_name”] = first
profile[“last_name”] = last
for key , value in user_info.items():
profile[key] = value
return profile
user_profile = my_profile(‘zhao’,‘yusai’,
location=‘princeton’,filed = ‘physics’)
print(user_profile)
#传递任意数量实参
new_name = []
def mf_name(*name):
new_name.append(name)
print(new_name)
mf_name(“胡超”)
friend = [’\nzhang’,‘wang’,‘lixue’]
mf_name(friend)
#传递列表
def my_friend(names):
for name in names:
print("\nmy friend name is: "+name)
friend_name=['wang','zhou','li']
my_friend(friend_name)