成都创新互联网站制作重庆分公司

创新互联Python教程:python判断list中某一元素是否存在

在python中判断 list 中是否包含某个元素:可以通过in和not in关键字来判断

例如:

abcList=['a','b','c',1,2,3]
    if 'a' in abcList:
        print('a is in abcList')
    if 'd' not in abcList:
        print('d is not in abcList')
    if 1 in abcList:
        print('1 is in abcList')

结果为:


本文题目:创新互联Python教程:python判断list中某一元素是否存在
网站URL:http://cxhlcq.com/article/dhehdeg.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部