码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-04-25 20:03:28      阅读:1105      评论:0      收藏:0      [点我收藏+]

标签:between   span   修改   类型   error   birt   pre   ror   col   

 

<不支持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'

标签:between   span   修改   类型   error   birt   pre   ror   col   

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

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!