python3xiaobaike_2020/chapter2/2-19 python3小白课:成员运算符.md
2025-04-20 23:22:14 +08:00

27 lines
764 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# python3小白课成员运算符
成员运算符可以测试某个成员在不在字符串、列表、元组里面,其中列表、元组我们后面会详细讲解,本节课我们可以先接触一下。
```python
# coding:utf-8
# 用in运算符探测成员在不在被测试者里面前面我们也提到过不知道大家还记得不返回布尔值结果
a = "he"
print(a in "hello")
# 用not in表示不在里面不在才返回True
print(a not in "little bai")
# 也可以判断在不在列表元素中,列表用[]表示
print(1 in [1, 3, 5])
# 判断在不在元组元素中,元组用()表示
print("bai" in ("blue", 1, 'yellow'))
```
### 单词释义
| 单词 | 释义 |
| ------ | ---- |
| blue | 蓝色 |
| yellow | 黄色 |