python中如何判断list中是否包含某个元素

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

pythontab = ['p','y','t','h','o','n','t','a','b']
if 't' in pythontab:
print 't in pythontab'
if 'w' not in theList:
print 'w is not in pythontab'

posted @ 2016-08-05 10:24  Jimny  阅读(24929)  评论(0编辑  收藏  举报