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

Posted 邓戈麟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TypeError: '<' not supported between instances of 'str' and 'int'相关的知识,希望对你有一定的参考价值。

 

<不支持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'的主要内容,如果未能解决你的问题,请参考以下文章

jQuery mobile报错 Uncaught TypeError: Cannot read property 'concat' of undefined

Uncaught TypeError: Cannot read property 'addEventListener' of null

Vue的报错:Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<

TypeError fun got multiple values for argument 'arg'

Vue的报错:Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<

Nativescript 5.3.1 TypeError:无法读取未定义的属性'getViewById'