try: something here except: print('the whatever error occurred.')
How can I print the error/exception in my except: block?
except:
(如何在我的except:块中打印错误/异常?)
For Python 2.6 and later and Python 3.x:
(对于Python 2.6和更高版本以及Python 3.x:)
except Exception as e: print(e)
For Python 2.5 and earlier, use:
(对于Python 2.5及更早版本,请使用:)
except Exception,e: print str(e)
2.1m questions
2.1m answers
60 comments
57.0k users