TypeError: can't multiply sequence by non-int of type 'str'

在3.0以上python中,input()函数,通过键盘输入返回值的类型是字符串,要用int、float等进行强制类型转换。
因为,input()函数是默认输入字符串,不管你输入的数字还是其他什么。。。

具体例子:Test.py

m = input()
n =input()
res = m*n
print(res)

在这里插入图片描述
修改:

m = input()
n =input()
res = int(m)*int(n)
print(res)

在这里插入图片描述

参考和引用:
https://zhidao.baidu.com/question/1368968745067898899.html

https://blog.csdn.net/jcwang710448116/article/details/77756733

https://blog.csdn.net/skyejy/article/details/82809754

仅用来个人学习和分享,如若侵权,留言立删。

尊重他人知识产权,不做拿来主义者!

喜欢的可以关注我哦QAQ,

你的关注和喜欢就是我write博文的动力。

猜你喜欢

转载自blog.csdn.net/AugustMe/article/details/100762678