用关键字 in 和not in 来
如下:
qwe =[1,2,3,4,5]
if 2 in qwe:
print ‘good!’
else:
print ‘not good’
666
本文介绍了一种使用Python中的in和notin关键字进行列表元素检查的方法。通过简单的代码示例展示了如何判断一个数值是否存在于特定的列表中。
用关键字 in 和not in 来
如下:
qwe =[1,2,3,4,5]
if 2 in qwe:
print ‘good!’
else:
print ‘not good’
666
4万+
8129

被折叠的 条评论
为什么被折叠?