代码示例:(标识:python_ref_keyword_except_3)
python_ref_keyword_except_3.py
# (x/0) raises a ZeroDivisionError:

try:
  x = 1/0
except NameError:
  print("You have a variable that is not defined.")
except TypeError:
  print("You are comparing values of different type")
except:
  print("Something else went wrong")
运行结果: