trackback模块的使用
使用trackback打印异常信息
1 import traceback 2 3 try: 4 print('step1') 5 num = 1/0 6 except: 7 traceback.print_exc()
将异常信息输入到指定文件中
1 import traceback 2 3 try: 4 print('step1') 5 num = 1/0 6 except: 7 with open('d:/a.txt','a') as f: 8 traceback.print_exc()