代码示例:(标识:python_try_except_1)
python_try_except_1.py
try:
  print(x)
except:
  print("An exception occurred")
运行结果: