Hướng dẫn dùng muliter python
Source code: Lib/webbrowser.py The Under Unix, graphical browsers are preferred under X11, but text-mode browsers will be used if graphical browsers are not available or an X11 display isn’t available. If text-mode browsers are used, the calling process will block until the user exits the browser. If the environment variable For non-Unix platforms, or when a remote browser is available on Unix, the controlling process will not wait for the user to finish with the browser, but allow the remote browser to maintain its own windows on the display. If remote browsers are not available on Unix, the controlling process will launch a new browser and wait. The script webbrowser can be used as a command-line interface for the module. It accepts a URL as the argument. It accepts the following optional parameters: python -m webbrowser -t "https://www.python.org" The following exception is defined: exceptionwebbrowser. Error ¶Exception raised when a browser control error occurs. The following functions are defined: webbrowser. open (url, new=0,
autoraise=True)¶Display url using the default browser. If new is 0, the url is opened in the same browser window if possible. If new is 1, a new browser window is opened if possible. If new is 2, a new browser page (“tab”) is opened if possible. If
autoraise is Note that on some platforms, trying to open a filename using this function, may work and start the operating system’s associated program. However, this is neither supported nor portable. Raises an auditing event webbrowser. open_new (url)¶Open url in a new window of the default browser, if possible, otherwise, open url in the only browser window. webbrowser. open_new_tab (url)¶Open url in a new page (“tab”) of the default browser, if possible, otherwise equivalent to webbrowser. get (using=None)¶Return a controller object for the browser type using. If using is webbrowser. register (name, constructor, instance=None, *, preferred=False)¶Register the browser type name. Once a browser type is
registered, the Setting preferred to Changed in version 3.7: preferred keyword-only parameter was added. A number of browser types are predefined. This table gives the type names that may be passed to the
Notes:
New in version 3.3: Support for Chrome/Chromium has been added. Here are some simple examples: url = 'https://docs.python.org/' # Open URL in a new tab, if a browser window is already open. webbrowser.open_new_tab(url) # Open URL in new window, raising the window if possible. webbrowser.open_new(url) Browser Controller Objects¶Browser controllers provide these methods which parallel three of the module-level convenience functions: controller. open (url, new=0, autoraise=True)¶Display url using the browser handled by this controller. If new is 1, a new browser window is opened if possible. If new is 2, a new browser page (“tab”) is opened if possible. controller. open_new (url)¶Open url in a new window of the
browser handled by this controller, if possible, otherwise, open url in the only browser window. Alias controller. open_new_tab (url)¶Open url in a new page (“tab”) of the browser handled by this controller, if possible, otherwise equivalent to
Footnotes 1Executables named here without a full path will be searched in the directories given in the |