in data if x>=0],推荐使用列表解析
data = [1,5,-3,-2,8,0,9] a = [x for x in data if x>=0] print(list(a))
字典...(字典解析){k:v for k,v in d.items() if v>90},python2用d.iteritems()
from random import randint
d = {x :...randint(60,100) for x in range(1,21)}
print(d)
dict = {k:v for k,v in d.items() if v>90}
print(dict)
集合...(集合解析){x for x in s if x%3==0}
from random import randint
data = [randint(-10,10) for x in range(10