[英]Print blank exception in python
我想弄清楚如果我一開始不知道異常是什么,該如何打印異常。 我該怎么辦?
try:
some_command
except:
print *full_exception_trace*
def exception(self)
try:
Something.objects.all()
except Exception, err:
print err.message #(if you want)
#raise err
raise # The 'raise' statement with no arguments inside an error
# handler tells Python to re-raise the exception with the
# original traceback intact
err.message將為您提供異常原因
traceback
模塊的print_exc()
函數似乎正是您想要的。 文件
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.