目录
概念与常见异常
多指在程序运行过程中,出现的未知异常或错误,语法和逻辑正确,可以通过其他代码进行处理
常见异常
# a=1/0
# ZeroDivisionError: division by zero
# print(name)
# NameError: name 'name' is not defined
# a = "1" + 2
# TypeError: can only concatenate str (not "int") to str
# l=[1,2]
# print(l[3])
# IndexError: list index out of range
# dic = {"name":"s"}
# print(dic["age"])
# KeyError: 'age'
# int("abc")
# ValueError: invalid literal for int() with base 10: 'abc'
# class A:
# a = 10
# A().b
# AttributeError: 'A' object has no attribute 'b'
# i = iter([1,2])
# prin