How to open a new default browser window in Python when the default is Chrome

I have been looking for a way to open a new default browser window from inside Python code.

According to the documentation webbrowser.open_new(url) Should do that. Unfortunately in case Chrome is the default browser it only opens a new tab. Is there any way to open the default browser (without knowing what that browser is)?


给这个旋转:

import subprocess
command = "cmd /c start chrome http://www.ebay.com --new-window"
subprocess.Popen(command, shell=True)

I have a feeling it's not Python's fault. Firefox and Chrome (and probably IE) all intercept calls to open new windows and changes them to new tabs. Check the settings in your browser for interpreting those calls.


webbrowser.open('http://www.google.com', new=1)
链接地址: http://www.djcxy.com/p/55056.html

上一篇: 这是我的jQuery脚本的好模式吗?

下一篇: 如果默认为Chrome,如何在Python中打开一个新的默认浏览器窗口