Sound alarm when code finishes

前端 未结 11 1027
离开以前
离开以前 2021-01-29 17:42

I am in a situation where my code takes extremely long to run and I don\'t want to be staring at it all the time but want to know when it is done.

How can I make the (Py

11条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-29 18:27

    Kuchi's answer didn't work for me on OS X Yosemite (10.10.1). I did find the afplay command (here), which you can just call from Python. This works regardless of whether the Terminal audible bell is enabled and without a third-party library.

    import os
    os.system('afplay /System/Library/Sounds/Sosumi.aiff')
    

提交回复
热议问题