python中遍历列表字典元组
-
lt = [
{'name':'小王', 'age':18, 'info':[('phone', '123'), ('dizhi', '广州')]},
{'name':'小芳', 'age':19, 'info':[('phone', '789'), ('dizhi', '深圳')]},
{'name':'小杜', 'age':22, 'info':[('phone', '567'), ('dizhi', '北京')]},
{'name':'小孟', 'age':28, 'info':[('phone', '000'), ('dizhi', '上海')]},
{'name':'小乔', 'age':26, 'info':[('phone', '111'), ('dizhi', '河南')]},
]
代码:
for i in lt:
print('我是{},年龄{},家住{},电话{}'.format(i['name'],i['age'],i['info'][1][1],i['info'][0][1]))
全世界的程序员们联合起来吧!