网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

python如何处理type(s) for +: 'int' and 'str'

时间:2024-10-12 00:37:28

1、首先介绍下今天用到的python版本,现在在用的版本有两个:一个是python2.7.15,一个是python3.6.5。今天这里用到的是3的版本。

python如何处理type(s) for +: 'int' and 'str'

3、程序开始会正常运行,当输入数字1,系统就会提示错。提示为“TypeError: unsupported operand type(s) for +: 'int' and 'str'”,这个错误就是说输入的字符类型没有被系统判定为整数类型。

python如何处理type(s) for +: 'int' and 'str'

5、重新运行一下,看到这次就没有再次报错,程序正常运行并计算出了我们想要的结果。

python如何处理type(s) for +: 'int' and 'str'
© 2025 五度知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com