为何返回一个字典时,提供的信息location = 'princeton'。(变量location =字符串'princeton')这里会变成键-值对呢,不是'location':'princeton'才对吗,而且location在打印的时候自动变成字符串而不是变量了。
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)