# Python中的逻辑运算符
# 1. and 运算符
# 当两个条件都为True时,结果才为True
x = True
y = False
print(x and y) # 输出: False
# 2. or 运算符
# 只要有一个条件为True,结果就为True
print(x or y) # 输出: True
# 3. not 运算符
# 取反操作,将True变为False,False变为True
print(not x) # 输出: False
print(not y) # 输出: True
# 组合使用逻辑运算符
age = 20
is_student = True
print(age > 18 and is_student) # 输出: True
print(age < 18 or is_student) # 输出: True
print(not (age > 18 and is_student)) # 输出: False
上一篇:python parquet
下一篇:python新手入门
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站