跳到内容

utf8-encoding-declaration (UP009) (utf8 编码声明 (UP009))

源自 pyupgrade linter。

修复总是可用的。

作用

Checks for unnecessary UTF-8 encoding declarations. (检查不必要的 UTF-8 编码声明。)

为什么这不好?

PEP 3120 makes UTF-8 the default encoding, so a UTF-8 encoding declaration is unnecessary. (PEP 3120 将 UTF-8 设置为默认编码,因此 UTF-8 编码声明是不必要的。)

示例

# -*- coding: utf-8 -*-
print("Hello, world!")

建议改为

print("Hello, world!")