from collections import defaultdict
values = [11,22,33,44,55,67,77,88,99,90,]my_dict = defaultdict(list)for value in values: if value>66: my_dict['k1'].append(value) else: my_dict['k2'].append(value)print(my_dict)本文共 265 字,大约阅读时间需要 1 分钟。
from collections import defaultdict
values = [11,22,33,44,55,67,77,88,99,90,]my_dict = defaultdict(list)for value in values: if value>66: my_dict['k1'].append(value) else: my_dict['k2'].append(value)print(my_dict)转载于:https://www.cnblogs.com/POP-w/p/7412127.html