【问题标题】:Python opening Default BrowserPython打开默认浏览器
【发布时间】:2021-03-26 02:01:55
【问题描述】:

所以我一直在用 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()

【问题讨论】:

标签: python tkinter browser


【解决方案1】:

这样试试

webbrowser.get('chrome').open('https://stackoverflow.com/')

webbrowser.get("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s").open("http://google.com")

【讨论】:

  • 我刚才试过了,不知道该放哪一行。有点混乱。
  • 这两种解决方案你都试试?
猜你喜欢
  • 1970-01-01
  • 2011-07-01
  • 2011-11-19
  • 1970-01-01
  • 2010-09-14
  • 2011-05-09
  • 2014-12-06
  • 2016-11-01
相关资源
最近更新 更多