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

birth是str类型

2000是int类型

所以无法对比,报错

 birth = input('birth: ')
if birth < 2000:
print('00前')
else:
print('00后')

修改为:

 s = input('birth: ')
birth = int(s)
if birth < 2000:
print('00前')
else:
print('00后')

TypeError: '<' not supported between instances of 'str' and 'int'的更多相关文章

  1. Python报错TypeError: '<' not supported between instances of 'str' and 'int'

    n = input() if n>=100:print(int(n)/10) else:print(int(n)*10) 报错内容: Traceback (most recent call la ...

  2. input()报错:TypeError: '>=' not supported between instances of 'str' and 'int'

    今天学习python基础—分支与循环,接触到了if.在练习一个if语句的时候,出现了错误. 题目是: 根据分数划分成四个级别:优秀.良好.及格.不及格,分数是72: grade = 72if grad ...

  3. python的强制转换(当出现 not supported between instances of 'str' and 'int' 的错误时)

    当我们编程时,有时会出现如下错误:TypeError: '>' not supported between instances of 'str' and 'int' 如下图: 这是因为input ...

  4. python报错:not supported between instances of 'str' and 'int'

    not supported between instances of 'str' and 'int' : 意思就是字符串不能和int类型的数值比较

  5. TypeError: sequence item 1: expected str instance, int found

    Error Msg Traceback (most recent call last): File "E:/code/adva_code/my_orm.py", line 108, ...

  6. 关于TypeError: strptime() argument 1 must be str, not bytes解析

    关于TypeError: strptime() argument 1 must be str, not bytes解析   在使用datetime.strptime(s,fmt)来输出结果日期结果时, ...

  7. Python之scrapy框架之post传输数据错误:TypeError: to_bytes must receive a unicode, str or bytes object, got int

    错误名:TypeError: to_bytes must receive a unicode, str or bytes object, got int 错误翻译:类型错误:to_bytes必须接收u ...

  8. python产生错误:can only concatenate str (not "int") to str

    代码为: #!/usr/bin/python # _*_ coding:utf-8_*_ # print("hello world!") name = input("na ...

  9. 刨根问底儿 -- intVal($str) 跟 (int) $str 的运算结果有什么区别

    intVal($str) 跟 (int) $str 都是把其他类型的变量转化为int型变量的方式,这么多年来我一直森森滴怀疑它们的运算结果在某些条件下会有区别.对于我的疑问,文档里也没有多说(或者我没 ...

随机推荐

  1. 深入理解Java虚拟机——读书笔记

    首先 强烈推荐周志明老师的这本书,真的可以说是(起码中文出版界)新手了解Java虚拟机必须人手一本的教科书!!!   第二部分自动内存管理机制 由于Java虚拟机的多线程是通过线程轮流切换并分配处理器 ...

  2. Python&Selenium 数据驱动【unittest+ddt+json+HTMLTestRunner】

    一.摘要 本博文将介绍Python和Selenium做自动化测试的时候,基于unittest框架,借助ddt模块使用json文件作为数据文件作为测试输入,最后借助著名的HTMLTestRunner.p ...

  3. 关于swap交换操作的新方法

    swap: 在oi中,swap用于交换两个变量的数值. 初学oi时,我们这样操作: 也就是说,需要一个temp变量来寄存x或y的值,因为当一个变量被赋值成为另一个变量时,没有temp它的值会丢失. 貌 ...

  4. JavaScript教程——JavaScript 的基本语法(标识符)

    标识符 标识符(identifier)指的是用来识别各种值的合法名称.最常见的标识符就是变量名,以及后面要提到的函数名.JavaScript 语言的标识符对大小写敏感,所以a和A是两个不同的标识符. ...

  5. opengles reference card

    https://www.khronos.org/files/opengles31-quick-reference-card.pdf https://www.khronos.org/opengles/s ...

  6. Java中的集合Collection、Iterator和Foreach用法(一)

    1.Java集合概述 在编程中,常常需要集中存放多个数据.当然我们可以使用数组来保存多个对象.但数组长度不可变化,一旦在初始化时指定了数组长度,则这个数组长度是不可变的,如果需要保存个数变化的数据,数 ...

  7. Educational Codeforces Round 33 (Rated for Div. 2) B题

    B. Beautiful Divisors Recently Luba learned about a special kind of numbers that she calls beautiful ...

  8. Python爬虫 Urllib库的基本使用

    1.构造Requset 其实上面的urlopen参数可以传入一个request请求,它其实就是一个Request类的实例,构造时需要传入Url,Data等等的内容.比如上面的两行代码,我们可以这么改写 ...

  9. FatMouse's Speed

    J - FatMouse's Speed DP的题写得多了慢慢也有了思路,虽然也还只是很简单的DP. 因为需要输出所有选择的老鼠,所以刚开始的时候想利用状态压缩来储存所选择的老鼠,后面才发现n太大1& ...

  10. 内置对象 Date

    1.内置对象     a)语言自带的对象     b)提供了常用的,基本的功能     Date 1.定义的方法          a) 获取当前时间 var date1=new Date(); co ...