How to open an application in Mac OS using Python

前端 未结 4 1060
忘掉有多难
忘掉有多难 2021-02-06 04:46

I want to open an application like TextEdit or Firefox in Mac OS using Python and wait till the applications exits. I can\'t figure out exact command to open an app and wait.

4条回答
  •  佛祖请我去吃肉
    2021-02-06 05:14

    AppleScript:

    tell app "Whatever you want" to open
    

    Call from Python

    import os
    os.system("""osascript -e 'tell app "Safari" to open'""")
    

提交回复
热议问题