How to close web browser using python

前端 未结 2 449
失恋的感觉
失恋的感觉 2021-02-04 14:55

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?

相关标签:
2条回答
  • 2021-02-04 15:36

    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")
    
    0 讨论(0)
  • 2021-02-04 15:39

    For MacOS, you can use below command:

    os.system("killall -9 'Google Chrome'")
    
    0 讨论(0)
提交回复
热议问题