定义默认字典值为列表类型

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)

posted @   pop_PY  阅读(432)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示