from threading import Timer import time def run1(): print(1) print(2) print(3) def run2(): print("A") print("B") print("C") if __name__ == "__main__": t1 = Timer(1, run1) #新建一个Time线程,设定启动1秒后执行函数run1 t2 = Timer(0, run2) #新建一个Time线程,设定启动0秒后执行函数run2 t1.start() #线程t1启动,1秒后输出 time.sleep(0.9) #暂停0.9秒 t2.start() #线程t2启动,即刻输出
A B C 1 2 3