📜  如何使用python代码示例制作计时器

📅  最后修改于: 2022-03-11 14:45:05.750000             🧑  作者: Mango

代码示例5
# The simplest way to create a timer is to use time.sleep and winsound
import winsound
min_time = int(input('How much time do you want set the timer to (in minutes)'))
sec_time = min_time * 60 
time.sleep(sec_time)
#Now for the sound, I'll use winsound.beep. You can use whatever you want
# Frequency is hoiw high or low pitched the sound to be (It's measured in Hz)
frequency = 500
# Duration is measured in milliseconds here. 1 second = 100 milliseconds
duration = 100
# I want it to beep 5 times, so I'll create a for loop.
for i in range(0,5):
    winsound.Beep(frequency,duration)