gpt4 book ai didi

python - 在 Python 代码中标记 "print"语句

转载 作者:太空狗 更新时间:2023-10-29 19:35:54 24 4
gpt4 key购买 nike

我不想在我们的 Python 模块中使用“打印”语句,因为我们将使用记录器。

我正在尝试生成一个脚本来使用 pylint 检查模块。但是,pylint 目前不会将此检测为警告或错误。

我想根据我们的内部 Python 编程标准将“打印”调用检测为错误或警告。

我怎样才能做到这一点?

最佳答案

flake8有一个flake8-print专门用于任务的插件:

flake8-print

Check for Print statements in python files.

演示:

$ cat test.py
s = "test"
print s

$ flake8 test.py
test.py:2:1: T001 print statement found.

关于python - 在 Python 代码中标记 "print"语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25249586/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com