python中的成员运算符是干嘛的_在Python中使用成员运算符的示例
下表列出了所有Python語言支持的成員運算符。
例如:
試試下面的例子就明白了所有的Python編程語言提供會員運算符:
#!/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"
if ( b not in list ):
print "Line 2 - b is not available in the given list"
else:
print "Line 2 - b is available in the given list"
a = 2
if ( a in list ):
print "Line 3 - a is available in the given list"
else:
print "Line 3 - a is not available in the given list"
當執行上面的程序它會產生以下結果:
Line 1 - a is not available in the given list
Line 2 - b is not available in the given list
Line 3 - a is available in the given list
原文:http://www.jb51.net/article/66051.htm
總結
以上是生活随笔為你收集整理的python中的成员运算符是干嘛的_在Python中使用成员运算符的示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 谷歌原生“短信”应用在 RCS 信息中支
- 下一篇: python逐行读取数据时出现错误_py