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 循环判断 先进行判断 在进行循环
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 循环判断 先进行判断 在进行循环
转载于:https://www.cnblogs.com/johnblog/p/5822374.html