python在运行过程中,程序解释机制会测试代码,如检测不通过则会抛出异常。
try:
aa = 10
bb = '10'
cc = aa + bb
except Exception as e:
print('error:',e)
#output输出异常,数字不能与字符向加
error: unsupported operand type(s) for +: 'int' and 'str'
try:
aa = 10
bb = '10'
cc = aa + bb
except TypeError as e:
print('错误信息;',e)