您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Python webbrowser.open()打开Chrome浏览器

Python webbrowser.open()打开Chrome浏览器

您可以使用Chrome的路径调用get()。下面是一个示例-用适合您平台的正确路径替换chrome_path。

import webbrowser

url = 'http://docs.python.org/'

# MacOS
chrome_path = 'open -a /Applications/Google\ Chrome.app %s'

# Windows
# chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'

# Linux
# chrome_path = '/usr/bin/google-chrome %s'

webbrowser.get(chrome_path).open(url)
python 2022/1/1 18:44:36 有322人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶