Python 打开默认浏览器
Python opening Default Browser
所以我一直在 Python 中编写搜索栏类型的东西,因为我很无聊。使用它搜索内容时,它会在 Internet Explorer 中打开,而不是在我的默认浏览器中打开 (Chrome)。
from tkinter import *
import webbrowser
win = Tk()
win.title("Search Bar")
def search():
url = entry.get()
webbrowser.open(url)
label1 = Label(win,text="Enter URL Here : "
,font=("arial",10,"bold"))
label1.grid(row=0,column=0)
entry = Entry(win,width=30)
entry.grid(row=0,column=1)
button = Button(win,text="Search",command=search)
button.grid(row=1,column=0,columnspan=2,pady=10)
win.mainloop()
这样试试
webbrowser.get('chrome').open('https://whosebug.com/')
或
webbrowser.get("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s").open("http://google.com")
所以我一直在 Python 中编写搜索栏类型的东西,因为我很无聊。使用它搜索内容时,它会在 Internet Explorer 中打开,而不是在我的默认浏览器中打开 (Chrome)。
from tkinter import *
import webbrowser
win = Tk()
win.title("Search Bar")
def search():
url = entry.get()
webbrowser.open(url)
label1 = Label(win,text="Enter URL Here : "
,font=("arial",10,"bold"))
label1.grid(row=0,column=0)
entry = Entry(win,width=30)
entry.grid(row=0,column=1)
button = Button(win,text="Search",command=search)
button.grid(row=1,column=0,columnspan=2,pady=10)
win.mainloop()
这样试试
webbrowser.get('chrome').open('https://whosebug.com/')
或
webbrowser.get("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s").open("http://google.com")