标签: itemgetter()

1 篇文章

Python学习记录13-通过某个关键字排序一个字典列表
本期的内容是有一个字典列表, 我想通过里面指定字典的一个key进行对这个字典列表进行排序。假设有以下的字典列表,我们想通过对这个列表里的字典的特定key来进行排序,可以使用operator的itemgetter来轻松实现。以下是根据fname和uid排序的代码:from operator import itemgetter rows = [ {'f…