python序列中是否包含某个元素

http://outofmemory.cn/code-snippet/9098/python-list-contains-with-in-not-in

 

theList = ['a','b','c']
if 'a' in theList:
    print 'a in the list'

if 'd' not in theList:
    print 'd is not in the list'
posted @ 2018-11-19 13:15  GXTon  阅读(2070)  评论(0编辑  收藏  举报