简体   繁体   中英

How to close web browser using python

I have opened a webbrowser window using webbrowser.open(url) in python now I want to close the webbrowser opened using python. Is it possible to do so?

There is no webbrowser.close, you can use these codes to close the task(in Windows OS):

First Import os package with

import os

then use system function to kill the task

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM