import traceback try: print('-------------------------') print(1/0) except: traceback.print_exc() #print('有异常')
E:\PycharmProjects\pythonProject\venv\Scripts\python.exe E:/PycharmProjects/pythonProject/demon1/demo36.py ------------------------- Traceback (most recent call last): File "E:/PycharmProjects/pythonProject/demon1/demo36.py", line 4, in <module> print(1/0) ZeroDivisionError: division by zero 进程已结束,退出代码0