练习题
Topic sourceif not isinstance(a,(int,float)):
raise TypeError('bad operand type a')
if not isinstance(b,(int,float)):
raise TypeError('bad operand type b')
if not isinstance(c,(int,float)):
raise TypeError('bad operand type c')
请问,这些有什么用那? a = float(input('please input a = '))在这一行代码中,如果输入了非数字,就会出Error了。 输入后一定是float,判断没什么用啊
- 1
Gussun
①等于号是,== ②检测参数合法性,需要一个个检测,并注意标注错误的发生地