<不支持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
时间: 2024-10-09 02:17:35