列表中的元素还可以是另一个列表,这种列表称为多为列表。只有一层嵌套的多维列表称为二维列表。
【语法】 变量=[[元素1,元素2…],[元素1,元素2…],…]
代码示例
employee_infos
=[["a1","王保华",10000],
["a2","李维新",5200],
["a3","张三",4500],
["a4","李四",3567],
["a5","张鑫",7896],
["a6","李默",9000] ]
for employee_info
in employee_infos
:
for intem
in employee_info
:
print(intem
,end
='')
print()
输出结果:
a1王保华
10000
a2李维新
5200
a3张三
4500
a4李四
3567
a5张鑫
7896
a6李默
9000