0
여기 내가하고있는 일이 있습니다. 나는 반응 시간 게임으로 노래가 끝난 후에 버튼을 눌러야 만한다.함수를 종료하는 방법은 무엇입니까?
if time.time() >= start + rng:
print("Click!!!")
return
내 질문은 : 나는 그것을 어떻게 최적화 할 수 있습니다
def play(melody, tempo, pause, pace=0.800):
start = time.time()
for i in range(0, len(melody)): # Play song
noteDuration = pace/tempo[i]
buzz(melody[i], noteDuration) # Change the frequency along the song
note
pauseBetweenNotes = noteDuration * pause
time.sleep(pauseBetweenNotes)
if time.time() >= start + rng:
print("Click!!!")
return
그래서 내 문제는 내가 시간이 범위가 너무 느린 기능을 종료 할 수있을 때 곡을 정지하는 데 사용하는이 부분이 있다는 것입니다 혹시라도 더 빨리 만들 수 있습니까?