python使用try中except出错提示 发表于 2019-04-18 | 分类于 python | 评论数: | 阅读次数: 本文字数: 554 | 阅读时长 ≈ 0:01 自建try出错信息显示程序。 自建print程序12345678910111213141516171819202122import tracebackdef print_e(msg='',wfile='errlog.txt',record_e=True,show_e=True): ''' 记录错误 :param msg: 信息 :param wfile: 错误文件目录 :param record_e: 是否记录到文件 :param show_e: 是否显示系统错误 :return: ''' if not msg is None: print(msg) if show_e: traceback.print_exc() if record_e: traceback.print_exc(file=open(wfile, 'a+'))try: a=1 b=0 c=a/bexcept: print_e(msg='err') 本文作者: WQian 本文链接: https://wqian.net/blog/2019/0418-python-print-index.html 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!