python sorted函數(結合使用lambda和operator.itemgetter()來對字典進行排序)

>>> mydict = { 'Li': ['M',7], ... 'Zhang': ['E',2], ... 'Wang': ['P',3], ... 'Du': ['C',2], ... 'Ma': ['C',9], ... 'Zhe': ['H',7] } >>> >>> from operator import itemgetter >>> sorted(mydict.iteritems(
相關文章
相關標籤/搜索