Python语言基础
Python语言进阶
Python数据结构

多个异常

多个异常详细操作教程
以下实例为学习多个异常,具体代码如下:
# Filename : example.py
# Author by : www.lidihuo.com
#The try block will generate a NameError, because x is not defined:
try:
  print(x)
except NameError:
  print("Variable x is not defined")
except:
  print("Something else went wrong")
执行以上代码输出结果为:
# Filename : example.py
# Author by : www.lidihuo.com

Variable x is not defined

昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4