首页 > 其他 > 详细

TypeError: '<' not supported between instances of 'str' and 'int'

时间:2018-04-25 19:50:19      阅读:1871      评论:0      收藏:0      [点我收藏+]

 

<不支持str实例和int实例之间的对比

 

birth是str类型

2000是int类型

所以无法对比,报错

 

1 birth = input(birth: )
2 if birth < 2000:
3     print(00前)
4 else:
5     print(00后)

 

修改为:

 

1 s = input(birth: )
2 birth = int(s)
3 if birth < 2000:
4     print(00前)
5 else:
6     print(00后)

 

TypeError: '<' not supported between instances of 'str' and 'int'

原文:https://www.cnblogs.com/denggelin/p/8946618.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!