Python3 简单的秒级定时器源码,每隔N秒运行指定函数的方法

import datetime,time,os
# cmd: python C:\Users\Unnamed\Desktop\dingshi.py
i=0;sched_time=10 #这里填秒数
while True:
    print (i)
    now = str(datetime.datetime.now())[:-7]
    if i==sched_time:
        print ('请在这里开始你的程序')
        # 也就是 cmd:cd C:\Users\Unnamed\Desktop\project_name
        os.chdir("C:\\Users\\Unnamed\\Desktop\\project_name")
        os.system('ls')
        print ('END')
        i=0
    time.sleep(1)
    print (now)
    i+=1


本文部分资料引用以下地址

https://github.com/wjb711/../定时器