python timer 每隔一段时间执行一次代码


def timer(interval=600, timeout=18000):
    """every 10min checking, 5hrs"""
    n = 1
    start_time = None
    if start_time == None:
        start_time = time.time()
    while True:
        if time.time() > start_time + timeout:
            PlayPage.pause_butt.click()
            print("end play" + time.asctime(time.localtime(time.time())))
            break
        elif (time.time() - start_time) % interval == 0:
            print(time.asctime(time.localtime(time.time())))  # checking time
            n += 1
            PlayPage.tips.is_Element_visible()
          
  

你可能感兴趣的:(python timer 每隔一段时间执行一次代码)