How to Close a program using python?

前端 未结 6 1555
小鲜肉
小鲜肉 2020-12-05 05:27

Is there a way that python can close a windows application (example: Firefox) ?

I know how to start an app, but now I need to know how to close one.

6条回答
  •  被撕碎了的回忆
    2020-12-05 05:54

    On OS X:

    1. Create a shell script and put:
    killall Application
    

    Replace Application with a running app of your choice.

    In the same directory as this shell script, make a python file. In the python file, put these two lines of code:

    from subprocess import Popen
    Popen('sh shell.sh', shell=True)
    

    Replace shell.sh with the name of your created shell script.

提交回复
热议问题