Python has a rich library of extensions and modules which are used for multiple purposes. To work with web-based content, Python provides a webbrowser module. The module creates an environment which enables the user to display web-based content in the application. To work with webbrowser, you have to make sure that it is installed in your local machine.
If the module is not available in your environment, then you can install it using the following command −
pip install webbrowser
Using the webbrowser module in our program, we will open an URL in our web browser. To open the URL in a default browser, we can use the open() function in the module.
# Import the required libraries import webbrowser # Add a URL to open in a new window url= 'https://www.tutorialspoint.com/' # Open the URL in a new Tab webbrowser.open_new_tab(url)
Running the above code will open the given URL in a new window of the default browser.