python模块中的suppress print()函数

发布于 2025-02-11 08:32:43 字数 98 浏览 0 评论 0原文

我正在每个模块中构建一个多模块Python程序,

我有一些功能,在调试每个单个模块

时,我在调试主体中调试模块功能时,

我用来打印一些输出?

I'm building a multi module python program

in each module i have some function where i used to print some output during debugging of each individual module

while calling modules's functions in the main program body those print function issues output

How I can suppress these print output ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩起发的微风 2025-02-18 08:32:43

一种解决方案是使用记录 class( https:https:/// docs.python.org/3/library/logging.html )由Python提供。通过使用loggging.debug而不是用于类调试消息的,如果main中的记录级别上方是debug(> 10),则将不会显示这些调试消息。

One solution is to use the Logging class (https://docs.python.org/3/library/logging.html) provided by python. By using logging.debug instead of print for class debug messages, if the logging level in main is above debug (>10), then these debug messages will not be displayed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文