如何检查python中是否弹出URL

如何检查python中是否弹出URL,python,Python,我有一个脚本,它在执行结束时弹出url 代码如下: path = os.path.dirname(os.path.abspath(__file__)) website = os.path.join(path, "home.html") webbrowser.open(website) 对于每次执行,都会弹出网站。有没有办法,我可以检查一下网站是否已经弹出。如果是,那么是否不再弹出 我不认为有办法轮询webbrowser以查看已经打开的内容,但从代码中可以保留一个已经打开的URL列表,如果不在该

我有一个脚本,它在执行结束时弹出url

代码如下:

path = os.path.dirname(os.path.abspath(__file__))
website = os.path.join(path, "home.html")
webbrowser.open(website)

对于每次执行,都会弹出网站。有没有办法,我可以检查一下网站是否已经弹出。如果是,那么是否不再弹出

我不认为有办法轮询webbrowser以查看已经打开的内容,但从代码中可以保留一个已经打开的URL列表,如果不在该列表中,则打开它们。根据列表的增长程度,最终需要使用数据库或类似的东西在内存之外处理它

请注意,这是不完整的,您将在每次运行此脚本时清除该列表。您需要将此概念用作更大功能应用程序的一部分,或者在出口处将列表写入桌面,并在开始时将其读回以维护历史记录

例如:

siteList = []
path = os.path.dirname(os.path.abspath(__file__))
website = os.path.join(path,"home.html")
if website not in siteList:
    siteList.append(website)
    webbrowser.open(website)

将您已经弹出的url添加到
集合
,并在再次弹出之前检查它是否在其中。@kindall:只有一个url。我是python新手,不知道怎么做。你能帮忙吗?