2021-03-26
阅读量:
1253
python报错 TypeError: '<'not supported between instances of 'str' and 'int'
问:
python报错 TypeError: '<'not supported between instances of 'str' and 'int'
答:
这是因为在python中input()语句输入的内容默认为字符串类型,而字符串类型的变量与整数型变量
之间不支持‘<’比较操作,因此会出现报错。解决方法是先将input()的内容转换为整数型,再进行比较,如下:






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论