python 错误提示TypeError: unsupported operand type(s) for ⼀⼀: ✀str✀ and ✀int✀

2025-02-23 07:06:01
推荐回答(2个)
回答1:

python 错误提示TypeError: unsupported operand type(s) for //: 'str' and 'int'是设置错误造成的,解决方法为;

1、图片中没有定义numi但是print函数里面用了所以出现命令错误。

2、例中if num = 44;写成了num==44,没满足if应有的语法引起的错误。

3、例中字符串类型的数据不能相乘引起的错误。

4、python需要严格的遵循缩进缩进不正常会引起错误。

回答2:

你用的应该是python3.x吧。
python3.x版本的input返回值是字符串。
python2.x版本的input是根据你输入的数据类型返回的。