7、表格数据使用字典和列表存储,并实现访问
a={"name":"高小一", "age"":18, "薪资":30000,"城市":"北京"}
b={"name":"高小二", "age"":19, "薪资":20000,"城市":"上海"}
c={"name":"高小三", "age"":20, "薪资":10000,"城市":"深圳"}
t=[a,b,c]
print(t[1].get("age")): 获取第二个的age项的值,
需求:遍历所有的薪资
for i in range(len(t)):
print(t[i].get("salary")
需求:打印表的所有数据
for i in range(len(t)):
print(t[i].get("name"),t[i].get("age"),t[i].get("薪资"),t[i].get("城市"))