日归档:
2006年04月03日
| 记录数: 1
-
- Python下为字典排序
- Weather:阴 ,东南风 4-5级 ,最低气温4 ℃
- 2006-04-03
<p># (IMHO) the simplest approach:<br /> def sortedDictValues1(adict):<br /> items = adict.items()<br /> items.sort()<br /> return [value for key, value in items]<br /> <br /> # an alternative implementation, which<br /> # happens to run a bit faster for large<br /> # dictionaries on my machine:<br /> def sortedDictValues2(adict):<br /> ...</p>
- Views(5332) | Comments(0) | In Python相关
