cf737e48ba895a5ac00d96a5b6eb560b7cf2e7ec
python/exeption\343\201\256stack trace\343\202\222\350\241\250\347\244\272\343\201\231\343\202\213.md
| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | +[python - How to catch and print the full exception traceback without halting/exiting the program? - Stack Overflow](https://stackoverflow.com/questions/3702675/how-to-catch-and-print-the-full-exception-traceback-without-halting-exiting-the) |
|
| 2 | + |
|
| 3 | +```python |
|
| 4 | +import traceback |
|
| 5 | +import sys |
|
| 6 | + |
|
| 7 | +try: |
|
| 8 | + do_stuff() |
|
| 9 | +except Exception: |
|
| 10 | + print(traceback.format_exc()) |
|
| 11 | + # or |
|
| 12 | + print(sys.exc_info()[2]) |
|
| 13 | +``` |
|
| ... | ... | \ No newline at end of file |