python程式碼:
import time import traceback from threading import Thread def fun1(): fun1_1() def fun2(): t = Thread(target=fun2_1()) t.start() def fun1_1(): print('fun1_1') def fun2_1(): 1 / 0 def main(): while True: try: time.sleep(1) fun1() fun2() except Exception: traceback.print_exc() if __name__ == '__main__': main()
效果圖: