###代码###
def build_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 = build_profile('albert','einstein',location='princeton', field='physics')
print(user_profile)
已上讲道理应该打印:{'first_name': 'albert', 'last_name': 'einstein', 'location': 'princeton','field':'physics'}
但是实际只有:{'first_name': 'albert', 'last_name': 'einstein', 'location': 'princeton'},没任何报错。Python 版本:3.6.5
def build_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 = build_profile('albert','einstein',location='princeton', field='physics')
print(user_profile)
已上讲道理应该打印:{'first_name': 'albert', 'last_name': 'einstein', 'location': 'princeton','field':'physics'}
但是实际只有:{'first_name': 'albert', 'last_name': 'einstein', 'location': 'princeton'},没任何报错。Python 版本:3.6.5