跳到内容

missing-whitespace-around-operator (E225)

源自 pycodestyle linter。

修复总是可用的。

此规则不稳定且处于预览状态。使用需要 --preview 标志。

作用

检查所有运算符周围是否缺少空格。

为什么这不好?

根据PEP 8,所有赋值运算符 (=)、增强赋值运算符 (+=-= 等)、比较运算符和布尔运算符前后都应有一个空格。

示例

if number==42:
    print('you have found the meaning of life')

建议改为

if number == 42:
    print('you have found the meaning of life')