TypeError: unsupported operand type(s) for -: ‘str’ and ‘str’
意思是:TypeError:不支持的操作数类型为-: 'str ‘和’ str ’
input输入的是字符串再赋值给变量,所以num1和num2都是字符串类型。字符串类型的不能进行相减乘除。所以解决报错方法为在input前可加上int将其转换为整数类型即可。
相关文章:
TypeError: unsupported operand type(s) for -: ‘str’ and ‘str’
意思是:TypeError:不支持的操作数类型为-: 'str ‘和’ str ’
input输入的是字符串再赋值给变量,所以num1和num2都是字符串类型。字符串类型的不能进行相减乘除。所以解决报错方法为在input前可加上int将其转换为整数类型即可。
相关文章: