티스토리 뷰

import threading

count = 0

def timer():
	global count
    count += 1
    print(count)
    
    timer = threading.Timer(1, timer) # 1초 마다 타이머 함수를 실행한다.
    timer.start()
    
   	if count == 5:
   		print('타이머를 멈춥니다.')
    	timer.cancel()
    
timer()

 

댓글