1.dict合并有返回值

解包法

c = {**a,**b}

 

2.排序list of dict or tuple

  以list of dict 为例

  1. 单个字段的排序

sorted(performance_info, key=lambda k: k[0])

2.多个字段排序

sorted(performance_info_list, key=lambda tup: (tup[1], tup[0]), reverse=True)

3.将list of tuple分组

[(key, value)
             for key, value in itertools.groupby(sorted(performance_info, key=lambda k: k[0]), lambda x: x[0])]

 4. 排序字典

dict(sorted(x.items(), key=lambda item: item[1]))