标签:
大于20都属于k1,小于等于属于k2
dic = {} li = [13,2,33,145,23,7,55,45,88,] for i in li: if i > 20: if ‘k1‘ in dic.keys(): dic[‘k1‘].append(i) else: dic[‘k1‘] = [i,] else: if ‘k2‘ in dic.keys(): dic[‘k2‘].append(i) else: dic[‘k2‘] = [i,] print(dic)
标签:
原文地址:http://www.cnblogs.com/jonyq/p/5925170.html