為何返回一個字典時,提供的信息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)
2019-01-02
....