def input_id():
#(1)请输入学号
id = input("请输入学号:")
if id == "5":
e = Exception("ID学号已存在")
raise e
else:
return id
id = ""
try:
id = input_id()
except Exception as e:
print("ID有问题: %s"%e)
id = input_id()
print("ID的值:%s"%id)
python 异常案例
最新推荐文章于 2023-01-07 10:02:47 发布