2

I am using webbrowser to open a URL using Python but the problem is after opening the URL webbrowser module prints unnecessary output on terminal. terminal output

I searched on google but didn't find any useful answer.

Code used:

import webbrowser

webbrowser.open("https://www.google.com/")

I just want to get rid of browser output in terminal not the whole output.

Vaibhav Singh
  • 1,554
  • 3
  • 13
  • 27

1 Answers1

1

You're looking for I/O redirection:

python script.py >/dev/null 2>&1

>/dev/null redirects stdout to /dev/null, preventing the terminal from outputting it.

2>&1 redirects stderr to stdout, which is then sent to /dev/null, to hide errors.

boxama
  • 58
  • 1
  • 5