字典
排序
dic={'name':23,'age':39,'job':48,'marriage':11}
print(dic)
print(sorted(dic))
print(sorted(dic.keys()))
print(sorted(dic.values()))
print(sorted(dic.items()))
遍历
dic={'name':'Kevin','age':39,'job':'teacher','marriage':True}
print(dic)
for i in dic:
print(i)
#推荐
for i in dic:
print(i,dic[i])
#不推荐,转换需要时间
for i in dic.items():
print(i)
for i,v in dic.items():
print(i,v)