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')
结果为:
来源:PY学习网:原文地址:https://www.py.cn/article.html