python 3 except sys error info code example

Example 1: try catch python

try:
  print("try to run this block")
except:
  print("run this bock if there was error in earlier block")

Example 2: python 3 except sys error info

1 import sys
   2 try:
   3   untrusted.execute()
   4 except: # catch *all* exceptions
   5   e = sys.exc_info()[0]
   6   write_to_page( "<p>Error: %s</p>" % e )

Example 3: try except python

try: #try to do the following
  print("Hi there")
except: #If what is meant to happen in (try) fails, do this.
  print("A error happened with the code above")

Tags:

Misc Example