导入pyBullet时,它会立即打印一行,并显示生成时的时间:
In [1]: import pybullet
pybullet build time: Jun 19 2020 04:01:58有什么办法可以防止这种情况发生吗?
发布于 2020-06-30 12:18:53
更改源代码。撇开玩笑不说,我认为没有任何明显的方法来防止这种情况发生。因为当您导入模块时会发生这种情况,所以在py子的配置中您所能做的不多。因为这是你用它做的第一件事
也许您可以在导入模块时重新路由stdout。这是一个重复的问题,这里已经回答了:Stop Python Module from Printing
发布于 2020-09-27 17:42:46
检查这些解决方案,在类似的问题上玩游戏。
Why when import pygame, it prints the version and welcome message. How delete it?
基于此,我建议:
import contextlib
with contextlib.redirect_stdout(None):
import pybullet完全归功于MadPhysicist
https://stackoverflow.com/questions/62657235
复制相似问题