Python: Change url of web browser using webbrowser-control

不羁的心 提交于 2021-01-28 20:03:53

问题


Ok, I know that if you want to open a particular url using pyton you would run:

import webbrowser
webbrowser.open("buinvent.com")

But what if you want to change it to a different url in the web browser without opening a new window or a new tab in the web browser. Is there a way to do that?


回答1:


import webbrowser
webbrowser.open('google.com', new = 0)

And the docs says:

If new is 0, the url is opened in the same browser window if possible. If new is 1, a new browser window is opened if possible. If new is 2, a new browser page (“tab”) is opened if possible

https://docs.python.org/3/library/webbrowser.html



来源:https://stackoverflow.com/questions/40443178/python-change-url-of-web-browser-using-webbrowser-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!