欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

python 定时器

程序员文章站 2022-03-03 10:02:29
...
def run():
    t = time.gmtime()
    hour = t.tm_hour + 8
    minute = t.tm_min
    sec = t.tm_sec
    if hour < 10:
        hour = hour
        hour = '0' + str(hour)
    if minute < 10:
        minute = '0' + str(minute)
    if sec < 10:
        sec = '0' + str(sec)

    print str(hour) + '.' + str(minute)
    curTime = str(hour) + '.' + str(minute)
    SAKS.digital_display.show(curTime)
    # print("timer run:" ,time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))
    global timer
    timer = threading.Timer(1, run)
    timer.start()

timer = threading.Timer(0,run)
timer.start()