Python-字典(嵌套)

笙烛

关注

阅读 112

2022-06-06

"""字典中嵌套字典"""users = {
'wen': {
'first': 'zhou', 'last': 'wen', 'location': 'hubei' }, 'tao': {
'first': 'zhou', 'last': 'tao', 'location': 'hubei' }
}

for username,userinfo in users.items():
print('username:'+username)
fullname = userinfo['first']+userinfo['last']
location = userinfo['location']
print('fullname:'+fullname)
print('location:'+location)
print('\t')

精彩评论(0)

0 0 举报