python模块中的suppress print()函数
我正在每个模块中构建一个多模块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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种解决方案是使用
记录
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 usinglogging.debug
instead ofprint
for class debug messages, if the logging level in main is above debug (>10), then these debug messages will not be displayed.