I have a library that I need to import on my code. However, whenever it is imported it outputs several lines of data to the console. How can I suppress the output?
Thanks
import os
import sys
# silence command-line output temporarily
sys.stdout, sys.stderr = os.devnull, os.devnull
# import the desired library
import library
# unsilence command-line output
sys.stdout, sys.stderr = sys.__stdout__, sys.__stderr__
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With