wechat_account = {'cshung':{'last_name':'洪','first_name':'锦魁','city':'台北'},'kevin':{'last_name':'郑','first_name':'义盟','city':'北京'}}
for account,account_info in wechat_account.items( ):print("使用者账号 =",account)name = account_info['last_name'] + account_info['first_name']print("姓名 =",name)print("城市 =",account_info['city'])
#################################################输出结果:
使用者账号 = cshung
姓名 = 洪锦魁
城市 = 台北
使用者账号 = kevin
姓名 = 郑义盟
城市 = 北京
#################################################重构一下:
wechat_account = {'cshung':{'last_name':'洪','first_name':'锦魁','city':'台北'},'kevin':{'last_name':'郑','first_name':'义盟','city':'北京'}}
for x,y in wechat_account.items( ):print("使用者账号 =",x)name = y['last_name'] + y['first_name']print("姓名 =",name)print("城市 =",y['city'])
#################################你悟...........................................