标签:
a= [1,2,3,4]b = ‘2‘
print [n for n in a if b in a]
[]
c = 2
print [n for n in a if c in a]
[1,2,3,4]
python 循环判断 先进行判断 在进行循环
python 条件和循环的使用方法
原文地址:http://www.cnblogs.com/johnblog/p/5822374.html