系统:Windows 7 语言版本:Anaconda3-4.3.0.1-Windows-x86_64 编辑器:pycharm-community-2016.3.2
Part 1:示例
Part 2:代码
list_1 = [1, 2, 3, 4, "a", "b"]
if "a" in list_1:
print("a is found")
else:
print("a is not found")
if "c" not in list_1:
print("c is not found")
str_1 = "Today is sunny"
if "o" in str_1:
print("o is found")
print("\ndone")
代码截图
运行结果
Part 3:部分代码解读
in
成员操作符返回一个布尔值,in
表示存在为True
,not in
表示不存在为True