直近例外のtracebackをprintする
import traceback try: 10/0 except Exception as e: # tarceback print(traceback.format_exc()) # おまけ:例外オブジェクトの型 print('{0}'.format(type(e))) # おまけ:例外オブジェクトのargsアトリビュート print('{0}'.format(e.args))
import traceback try: 10/0 except Exception as e: # tarceback print(traceback.format_exc()) # おまけ:例外オブジェクトの型 print('{0}'.format(type(e))) # おまけ:例外オブジェクトのargsアトリビュート print('{0}'.format(e.args))