li=[11,22,33,44,66,77,88] dict={} li_less=[] li_large=[] for i in li: if i == 66:continue if i < 66: li_less.append(i) else: li_large.append(i) dict.setdefault('k1',li_less) dict.setdefault('k2',li_large) print(dict)
排序数组,并将大小数组放回字典。
li=[11,22,33,44,66,77,88] dict={} li_less=[] li_large=[] for i in li: if i == 66:continue if i < 66: li_less.append(i) else: li_large.append(i) dict.setdefault('k1',li_less) dict.setdefault('k2',li_large) print(dict)
排序数组,并将大小数组放回字典。