Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我用下面的代码打开新的网址
webbrowser.open(url)
这在默认浏览器中打开了 url,但我需要在已经打开的浏览器会话中打开它。
另外,有没有办法在浏览器的特定选项卡中打开 URL?
您应该使用webbroser.get([name]):返回浏览器类型名称的控制器对象。如果 name 为空,则返回适合调用者环境的默认浏览器的控制器。
webbroser.get([name])
演示:
import webbrowser url = 'http://www.google.com' browser = webbrowser.get('firefox') # or lynx, opera browser.open(url)