Python and 关键字
定义和用法
and 关键字是逻辑运算符。
逻辑运算符用于组合条件语句。
如果两条语句都返回 True,则返回值将为 True,否则返回 False。
实例
例子 1
如果两条语句均为 True,则返回 Return:
x = (5 > 3 and 5 < 10) print(x)
例子 2
在 if 语句中使用 and 关键字:
if 5 > 3 and 5 < 10:
print("Both statements are True")
else:
print("At least one of the statements are False")
相关页面
教程:Python 运算符