python input exception code example
Example 1: exception pyton print
except Exception as e: print(e)
Example 2: python 3 except sys error info
1 import sys
2 try:
3 untrusted.execute()
4 except:
5 e = sys.exc_info()[0]
6 write_to_page( "<p>Error: %s</p>" % e )
Example 3: exception variable properties python
>>> try:
... raise Exception('spam', 'eggs')
... except Exception as inst:
... print(type(inst))
... print(inst.args)
... print(inst)
...
... x, y = inst.args
... print('x =', x)
... print('y =', y)
...
<class 'Exception'>
('spam', 'eggs')
('spam', 'eggs')
x = spam
y = eggs