Мой код таков:
import time
import winsound
frequency = 2500
duration = 1000
while time.perf_counter() < 5:
print(time.perf_counter())
winsound.Beep(frequency, duration)
Как мы можем печатать только секунды?
Наивный подход, замените цикл while на:
sec = 0
while time.perf_counter() < 5:
now = max(round(time.perf_counter()), sec)
if now > sec:
sec = now
print(sec)