如何使用python关闭web浏览器

如何使用python关闭web浏览器,python,python-webbrowser,Python,Python Webbrowser,我已经用python中的webbrowser.open(url)打开了一个webbrowser窗口,现在我想关闭用python打开的webbrowser。可以这样做吗?没有webbrowser.close,您可以使用以下代码关闭任务(在Windows操作系统中): 首次使用导入操作系统包 import os 然后使用系统函数终止任务 os.system("taskkill /im firefox.exe /f") os.system("taskkill /im chrome.exe /f")

我已经用python中的
webbrowser.open(url)
打开了一个webbrowser窗口,现在我想关闭用python打开的webbrowser。可以这样做吗?

没有webbrowser.close,您可以使用以下代码关闭任务(在Windows操作系统中):

首次使用导入操作系统包

import os
然后使用系统函数终止任务

os.system("taskkill /im firefox.exe /f")
os.system("taskkill /im chrome.exe /f")

对于MacOS,您可以使用以下命令:

os.system("killall -9 'Google Chrome'")

你看到了吗:请看这个:我们在chrome隐姓埋名窗口中使用的扩展名是什么?