pzx-web-api/app/util/common.py

19 lines
325 B
Python
Raw Normal View History

2023-08-10 12:27:18 +08:00
import os
from itertools import groupby
from operator import itemgetter
2023-08-12 20:00:38 +08:00
2023-08-10 12:27:18 +08:00
def split_group(dict_list, key):
dict_list.sort(key=itemgetter(key))
tmps = groupby(dict_list, itemgetter(key))
result = []
for key, group in tmps:
result.append({key: list(group)})
return result
basedir = os.getcwd()
2023-08-11 16:36:56 +08:00