版权声明:版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37960324/article/details/84138594
Python学习(二)常见问题(5):TypeError: unsupported operand type(s) for +: 'int' and 'str'
在键入数值进行相加运算时,报了这样一个错误
类型错误:不支持操作类型为整数和字符串
错误分析:sum=sum+input() 未被系统识别,导致程序错误
解决方法:给键入的数值定义,声明为整数
sum=sum+int(input()) 即可
执行结果: