在python中可以通过in和not in关键字来判读一个list中是否包含一个元素
|
1
2
3
4
5
|
pythontab = ['p','y','t','h','o','n','t','a','b']if 't' in pythontab: print 't in pythontab'if 'w' not in pythontab: print 'w is not in pythontab' |
in 和 not in 是非常常用的关键字。
感谢@飞飞指正错误
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END












暂无评论内容