合并列表创建字典
>>> lista=["name","age","gender"]
>>> listb=["zhangsan",99,"wu"]
>>> dict1={lista[i]:listb[i] for i in range(len(lista))}
>>> dict1
{'name': 'zhangsan', 'age': 99, 'gender': 'wu'}
字典里获取指定的数据
>>> worker={"linux":18,"java":120,"php":800,"python":160,"aid":700,"bigData":200} #定义字典,元素
>>> for k,v in worker.items():
... print (k,v)
...
linux 18
java 120
php 800
python 160
aid 700
bigData 200
>>> num={k:v for k,v in worker.items() if v<100} #获取小于100的数据
>>> print (num)
{'linux': 18}
内建函数
!!!!!
反转
>>> L2=[1,3,5,7,9]
>>> L2.reverse()
>>> print(L2)
[9, 7, 5, 3, 1]
排序(升序降序)
>>> L4=[34,29,58,63]
>>> sorted(L4)
[29, 34, 58, 63]
>>> sorted(L4,reverse=True)
[63, 58, 34, 29]