# try 代码块会产生 NameError 异常,因为变量 x 未定义:
try:
print(x) # 尝试访问未定义的变量
except NameError:
print("变量 x 未定义")
except:
print("发生了其他错误")