python time测试

python time测试

 

import time

def timer(seconds):
    start_time = time.time()
    while True:
        elapsed_time = time.time() - start_time
        if elapsed_time >= seconds:
            break
    print("Time's up!")

  

timer(10) # runs for 10 seconds

  

 

#####################

posted @ 2023-04-09 19:11  西北逍遥  阅读(25)  评论(0编辑  收藏  举报