try: print('try...') r = 10 / int('2') print('result:', r) except ValueError as e: print('ValueError:', e) except ZeroDivisionError as e: print('ZeroDivisionError:', e) else: print('no error!') finally: print('finally...') print('END')
import loggingpython
logging.baseConfig(level=logging.INFO)調試
…blog
logging.info(‘此處有錯誤’)io
提示優先順序爲:DEBUG INFO WARNING ERROR四種class