pylint disable=<something>和/usr/bin/env python的相同python文件

2024-10-01 00:33:36 发布

您现在位置:Python中文网/ 问答频道 /正文

问题很简单,我在Python脚本中有两行:

# pylint: disable=C0301, W0212
#!/usr/bin/env python

他们两个都必须在一线,否则他们就不能工作了。在

你建议我怎么解决这个问题?在


Tags: env脚本binusr建议pylintdisablew0212
2条回答

以下是第一行:

#!/usr/bin/env python

Pylint消息可以在任何线路上发送。如文件所述:

Is it possible to locally disable a particular message? This may be done by adding “#pylint: disable=W0123,E4567” at the desired block level or at the end of the desired line of code

所以消息需要在相同的块级别(这样第二行就可以工作了,这是相同的块/范围)。此外,文件还说:

Is there a way to disable a message for a particular module only? Yes, you can disable or enable (globally disabled) messages at the module level by adding the corresponding option in a comment at the top of the file:

所以它不会说:“文件的第一行”;只要禁用消息在文件的顶部,就可以了。在

Pylint禁用注释不需要在最上面一行才能工作。在

相关问题 更多 >