PyCharm黄色波浪线提示: Simplify chained comparison

译过来就是,可简化比较链:spa

case 1

if a >= 0 and a <= 9:

可简化为:code

if 0 <= a <= 9:

就像咱们的数学表达式同样。显然这种情形只适用于 and 的情形。blog

case 2

if score > 100 and score < 0:

会被简化为:数学

if 100 < score < 0:

显然这也是一个永假式,不怪 PyCharm 不够智能,只是你把表达式写错了:class

if score > 100 or score < 0:
相关文章
相关标签/搜索