try:
pass
except Exception as e:
trace_file=open(trace_file_path, 'a')
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),file=trace_file)#记录报错的时间
traceback.print_exc(file=trace_file)#输出报错到文件
trace_file.close()
traceback.print_exc()#打印报错(如果不加这一行则只输出到文件)

发表评论

邮箱地址不会被公开。 必填项已用*标注