Python error handling and python error handling
It is inconvenient to use the error code to indicate whether an error occurs. Because the normal results returned by the function itself are mixed with the error code, the caller must use a large amount of code to determine whether an error occurs:
Def foo (): r = some_function () if r = (-1): return (-1) # do something return rdef bar (): r = foo () if r = (-1): print 'error' else: pass
But that's what Go does. Haha!
In python, try… is still used... Else t .... Finally.
Try: print 'try... 'r = 10/0 print 'result: ', rexcept ZeroDivisionError, e: print 'couldn't:', efinally: print 'Finally... 'print 'end'
Articles you may be interested in:
- Python exception handling instance details
- Python exception handling Summary
- Introduction to five exception handling mechanisms in python
- Python error handling
- Zero-Basic python crawler-based HTTP Exception Handling
- Python standard exception and Exception Handling
- How to handle socket remote connection errors in python
- Python implements Remote File Reading with error handling
- Tutorial on Exception Handling in Python Programming