Python Membership Operators
来源:互联网 发布:保健品电话数据资源 编辑:程序博客网 时间:2024/06/08 18:00
In addition to the operators discussed previously, Python has membership operators, which test for membership in a sequence, such as strings, lists or tuples. There are two membership operators explained below:
OperatorDescription
Example
InEvaluates to true if it finds a variable in the specified sequence and false otherwise.x in y, here in results in a 1 if x is a member of sequence y.not inEvaluates to true if it does not finds a variable in the specified sequence and false otherwise.x not in y, here not in results in a 1 if x is not a member of sequence y.
Example:
Try following example to understand all the membership operators available in Python programming language:
#!/usr/bin/python
a = 10
b = 20
list = [1, 2, 3, 4, 5 ];
if ( a in list ):
print "Line 1 - a is available in the given list"
else:
print "Line 1 - a is not available in the given list"
0 0
- Python Membership Operators
- Python中的 equality operators
- Python en:Operators and Expressions
- python: Bitwise Operators (位运算)
- Operators
- Operators
- Operators
- Operators
- [Python]--SciPy Indexing and Python Basic Operators
- Membership
- membership
- MemberShip
- How to override comparison operators in Python
- Python 入门教程 16 ---- Introduction to Bitwise Operators
- python之二types and operators
- Membership学习membership入门
- XPath Operators
- 14.2 Operators
- WPF党旗和国徽!
- sipdroid的编译以及导入Eclipse环境
- MFC 错误归类
- Automatic Statistics Gathering
- Linux命令实践:特殊Linux命令补充
- Python Membership Operators
- 12306刷票脚本
- android bluetooth 移植相关注意事项
- Linux那些事儿之我是SCSI硬盘(2)依然probe
- DBGrid 各属性的设置
- 使用ffmpeg快速生成视频截图
- 使用在线重定义方式将普通表转换成分区表
- String、StringBuffer、StringBuilder的比较
- iOS 系统信息