Python语言中的逻辑运算符主要包括与(and)、或(or)、非(not)三类,用于布尔值的运算,结果返回布尔值(True/False)。一、与运算符(and)1. 语法:`表达式1 and 表达式2`2. 运算规则:只有当两个表达式都为`True`时,结果才为`True`;只要有一个表达式为`False`,结果即为`False`3. 短路特性:若`表达式1`为`False`,则直接返回`False`,不会执行`表达式2`4. 示例:`3 > 2 and 5 < 10` → `True`;`1 == 2 and 6 > 3` → `False`二、或运算符(or)1. 语法:`表达式1 or 表达式2`2. 运算规则:只要有一个表达式为`True`,结果即为`True`;只有两个表达式都为`False`时,结果才为`False`3. 短路特性:若`表达式1`为`True`,则直接返回`True`,不会执行`表达式2`4. 示例:`2 + 2 == 5 or 3 * 3 == 9` → `True`;`10 > 20 or 5 < 3` → `False`三、非运算符(not)1. 语法:`not 表达式`2. 运算规则:对表达式的布尔值取反,`True`变`False`,`False`变`True`3. 示例:`not (3 > 5)` → `True`;`not True` → `False`四、逻辑运算符的优先级1. 优先级从高到低:`not` > `and` > `or`2. 可通过括号`()`调整优先级3. 示例:`not 3 > 5 and 2 < 1` → 先算`not False`得`True`,再算`True and False`得`False`五、与其他运算符的结合1. 逻辑运算符常与比较运算符(`==`、`>`、`<`等)结合使用2. 可用于条件判断(`if`语句)、循环控制(`while`语句)等场景3. 示例:`if age > 18 and height > 160: print("符合条件")`