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

时间:2018-04-25 19:50:19   收藏:0   阅读:1874

 

<不支持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后)

 

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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!