Python 3.x 如何在python中打开google chrome

Python 3.x 如何在python中打开google chrome,python-3.x,Python 3.x,我尝试过编写各种python代码,但在我的电脑上找不到任何可以工作的 def UI(): os.system('cls' if os.name == 'nt' else 'clear') choice1=input("Pick a program: ") if choice1=='Google': ('https://www.google.com/') 这就是我想到的全部 如果有人有任何答案,请告诉我 import webbrowser url = 'http://docs.pyth

我尝试过编写各种python代码,但在我的电脑上找不到任何可以工作的

def UI():
os.system('cls' if os.name == 'nt' else 'clear')
choice1=input("Pick a program: ")
if choice1=='Google':   
 ('https://www.google.com/')
这就是我想到的全部

如果有人有任何答案,请告诉我

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)
您可以使用Chrome的路径调用get()。下面是一个示例-将chrome_路径替换为您平台的正确路径。

在Windows中使用
os.system('start chrome')
os.system('start chrome{}.format(site))
或在Linux中使用
os.system('google-chrome{}.format(site))
,其中
site
是您要查找的站点的URL。

以下是一种方法: