Python中比较运算符连用的语法规则
在Python中,比较运用符<、>、<=、>=、== 、!=可以连用,但语法规则和其它编程语言不一样
以 == 为例,具体语法规则是:
a == b == c == d 等价于 a == b and b == c and c == d
a = '赵敏'
b = '张无忌'
c = '张无忌'
d = '赵敏'
print(a != b == c != d)
输出结果是:
在Python中,比较运用符<、>、<=、>=、== 、!=可以连用,但语法规则和其它编程语言不一样
以 == 为例,具体语法规则是:
a == b == c == d 等价于 a == b and b == c and c == d
a = '赵敏'
b = '张无忌'
c = '张无忌'
d = '赵敏'
print(a != b == c != d)
输出结果是: