Python-syntax errors and exception
1. syntax errors (arrow marks)
2. zero division error, name error, type error.
3. try again t
While True:
Try:
X = int (raw_input ("Input :"))
Break
Failed t ValueError:
Print "Something wrong and re-input"
Not enough t will spread this error to up-level try.
Failed t (RuntimeError, TypeError, NameError), allow more than one failed t and the last modified t doesn't need to write the errors
Can add else at the end of each t, code after this can execute when no exception.
4. force failure t
Try:
Raise NameErrZ restart? Http://www.bkjia.com/kf/ware/vc/ "target =" _ blank "class =" keylink "> vciw =" hahah' # error name and parameter
Failed t NameError:
Print 'afdafd'
Raise # another throw
5. user defined errors
6. clean
File or network
Finally will execute no matter exception happed
If exception happened, after execute finally code and will throw again