在Python中使用成员运算符的示例
作者:goldensun 时间:2023-12-12 01:36:20
下表列出了所有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
标签:Python
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python统计日志ip访问数的方法
2023-07-05 18:57:20
MYsql库与表的管理及视图介绍
2024-01-25 21:33:06
![](https://img.aspxhome.com/file/2023/4/67084_0s.png)
ThinkPHP框架下微信支付功能总结踩坑笔记
2024-05-02 17:13:41
![](https://img.aspxhome.com/file/2023/7/129837_0s.png)
openCV中值滤波和均值滤波的代码实现
2023-07-22 06:08:28
![](https://img.aspxhome.com/file/2023/9/134269_0s.jpg)
跟老齐学Python之list和str比较
2021-02-26 22:36:36
如何完美的建立一个python项目
2021-02-20 21:07:26
jquery实用技巧之输入框提示语句
2024-04-22 12:49:10
![](https://img.aspxhome.com/file/2023/1/136091_0s.jpg)
如何在SQL2000的查询中使用XML-Data?
2010-06-18 19:26:00
使用Python中tkinter库简单gui界面制作及打包成exe的操作方法(二)
2023-04-25 19:32:40
微信小程序应用号开发教程详解
2022-07-05 00:34:50
![](https://img.aspxhome.com/file/2023/9/112089_0s.png)
SQL Server性能调优之缓存
2024-01-25 04:30:08
Python中new方法的详解
2022-12-06 14:20:18
如何恢复/修复MS SQL数据库的MDF文件
2007-10-30 13:52:00
pytorch实现CNN卷积神经网络
2023-07-04 20:23:06
IDEA导入Git项目的方法
2023-01-25 23:09:09
![](https://img.aspxhome.com/file/2023/5/132245_0s.png)
JavaScript实例--实现计算器
2024-04-23 09:26:17
![](https://img.aspxhome.com/file/2023/0/135530_0s.png)
Python利用Beautiful Soup模块搜索内容详解
2023-10-24 15:53:43
python画柱状图--不同颜色并显示数值的方法
2021-12-31 17:22:18
![](https://img.aspxhome.com/file/2023/6/121666_0s.jpg)
Python入门教程之Python的安装下载配置
2021-08-18 06:01:14
![](https://img.aspxhome.com/file/2023/7/86597_0s.png)
Python基于jieba分词实现snownlp情感分析
2023-11-14 21:43:38
![](https://img.aspxhome.com/file/2023/0/63590_0s.jpg)