简体   繁体   中英

How to suppress python output to screen?

I am using python.

The following line of code prints some information to the screen:

p = open3d.read_point_cloud("data.ply") ,

which prints Reading PLY: [========================================] 100%

I want to suppress the printed information.

I tried this:

text_trap = io.StringIO()
sys.stdout = text_trap

p = open3d.read_point_cloud("data.ply")

sys.stdout = sys.__stdout__

However it does not work. I found the implementation of this function to be inside a .so file.

Can anyone provide help? Appreciate it!

I wanted to add this as a comment but, I don't have enough rep to add comments, so Typing it as a answer.

Have you tried to use the print_progress parameter, this might solve your problem

p = open3d.read_point_cloud("data.ply",print_progress=False)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM