自定一个 stopWathc(m, s) 函数,m 表示分钟数, s 表示秒数。调用此函数,经过指定的时间后播放提示音乐。

代码:

import time, subprocess

def stopWatch(m, s):
    timeLeft = 60*m + s
    while timeLeft > 0:
        print(timeLeft, end='')
        time.sleep(1)
        timeLeft -= 1

    #倒计时结束,播放提示音乐。
    subprocess.Popen(['start', 'alarm.mp3'], shell=True)

 

相关文章:

  • 2021-07-29
  • 2021-11-25
  • 2021-11-14
  • 2021-12-15
  • 2022-01-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-22
  • 2022-12-23
  • 2021-12-13
  • 2022-12-23
  • 2022-01-17
相关资源
相似解决方案