如何打开Python中的新的默认的浏览器窗口时,默认为浏览器 [英] How to open a new default browser window in Python when the default is Chrome

查看:1301
本文介绍了如何打开Python中的新的默认的浏览器窗口时,默认为浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一种方式来在Python code里面打开一个新的默认浏览器窗口。

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

根据文档的 webbrowser.open_new(URL)
应该这样做。不幸的情况下,Chrome是只打开一个新标签的默认浏览器。
有没有什么办法打开默认浏览器(不知道浏览器是什么)?

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)

这篇关于如何打开Python中的新的默认的浏览器窗口时,默认为浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆