li = [11,22,33,44,55,66,77,88,99]分类

方法一:

li = [11,22,33,44,55,66,77,88,99]
s = []
m = []
for i in li:
if i <= 55:
s.append(i)

else:
m.append(i)

print(s)
print(m)

方法二:
li = [11,22,33,44,55,66,77,88,99]
dic = {
'k1':[],
'k2':[]
}
for i in li:
if i <= 55:
dic['k1'].append(i)
else:
dic['k2'].append(i)
print(dic)
posted @ 2017-11-06 11:16  口水哥  阅读(326)  评论(0编辑  收藏  举报