代码示例:(标识:python_ref_keyword_except_4)
python_ref_keyword_except_4.py
# (x > 10) will not raise any errors:

x = 1

try:
  x > 10
except NameError:
  print("You have a variable that is not defined.")
except TypeError:
  print("You are comparing values of different type")
else:
  print("The 'Try' code was executed without raising any errors!")
运行结果: