input()报错:TypeError: '>=' not supported between instances of 'str' and 'int'
今天学习python基础—分支与循环,接触到了if。在练习一个if语句的时候,出现了错误。
题目是: 根据分数划分成四个级别:优秀、良好、及格、不及格,分数是72:
grade = 72
if grade >= 90:
print('优秀')
elif grade >=70:
print('良好')
elif grade >=60:
print('及格')
else:
print('不及格')
grade = input('请输入你的分数:')
if grade >= 90:
print('优秀')
elif grade >=70:
print('良好')
elif grade >=60:
print('及格')
else:
print('不及格')
报错原因是:input()输入的内容是一个字符串,字符串跟整型数值进行比较,类型不匹配
修改方法:
input()报错:TypeError: '>=' not supported between instances of 'str' and 'int'的更多相关文章
- 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 ...
- python报错:not supported between instances of 'str' and 'int'
not supported between instances of 'str' and 'int' : 意思就是字符串不能和int类型的数值比较
- TypeError: '<' not supported between instances of 'str' and 'int'
<不支持str实例和int实例之间的对比 birth是str类型 2000是int类型 所以无法对比,报错 birth = input('birth: ') if birth < 2000 ...
- python的强制转换(当出现 not supported between instances of 'str' and 'int' 的错误时)
当我们编程时,有时会出现如下错误:TypeError: '>' not supported between instances of 'str' and 'int' 如下图: 这是因为input ...
- python pip install 报错TypeError: unsupported operand type(s) for -=: 'Retry' and 'int' Command "python setup.py egg_info" failed with error code 1 in
pip install http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp27-cp27mu-manylinux1_x86_64.whl ...
- 解决pip安装时出现报错TypeError unsupported operand type(s) for -= 'Retry' and 'int'
1.参考 https://stackoverflow.com/questions/42610545/typeerror-unsupported-operand-types-for-retry-and- ...
- PyCharm启动报错 TypeError: unsupported operand type(s) for /: ‘str’ and ‘str’ 解决
这个提示大概是说:"类型错误:不支持操作类型为字符串和字符串",直接把两个字符串(BASE_DIR = os.path.dirname(os.path.dirname(os.pat ...
- firefox浏览器中使用vux的x-input报错TypeError: _this3.$refs.input.scrollIntoViewIfNeeded is not a function
最近做公众号项目,想着统一风格,所以决定使用vux. 在调试时发现,只要鼠标点击x-input输入框,就会报错 TypeError: _this3.$refs.input.scrollIntoView ...
- [转载]UEditor报错TypeError: me.body is undefined
本文转载来自:UEditor报错TypeError: me.body is undefined 今天在使用UEditor的setContent的时候报错,报错代码如下 TypeError: me.bo ...
随机推荐
- vue.js--基础 v-bind绑定属性使用
背景:因为10月要休产假了,8月的时间我工作很少,因为最开始做平台我一直做的是后端,前端很少接触,所以现在有时间,就学习前端基础,前端使用的vue.js+element,因为没有基础,所以下了一个视频 ...
- 广搜最短路(最短时间到达目的地),POJ(3669)
题目链接:http://poj.org/problem?id=3669 解题报告: 1.流星坠落的点,四周和自己本身都被毁灭,不断更新每个点被毁灭的时候的最短时间. 2.搜索终点是,到达某个点,这个不 ...
- MySQL 数据库和一些常用命令的使用
常用命令总结: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 3 ...
- VC-基础:VS2010/MFC-1MFC消息映射
Windows消息分类 Windows消息分为系统消息和用户自定义消息.Windows系统消息有三种: 1.标准Windows消息.除WM_COMMAND外以WM_开头的消息是标准消息.例如,WM_C ...
- spfa判负权边
spfa判负环 如果一个点在spfa中被入队了大于n次 那么,我们就能肯定,有负环出现. 因为一个点入队时,他肯定被更新了一次. 所以........ 如果不存在负权环.这个点最多被更新节点数次 我们 ...
- SQL按时间段统计(5分钟统计一次访问量为例,oracle统计)
需求:统计当天的访问量,每五分钟采集一次 表结构中有日期字段,类型TIMESTAMP 如果,统计是采用每秒/分钟/小时/天/周/月/年,都非常容易实现,只要to_char日期字段然后group by分 ...
- 刚学不久的python,自己稍微加工了一点,影响不大,因为博主很懒,所以格式什么的,就没有太在意了!
本人初学python,之前因为有接触过其他语言,但是并没有接触的太深,出于对一个hacker的向往,学习一下Linux和python再说,当然,也是为了高工资啦,啊哈哈哈! 一开始就是一个蛮有意思的小 ...
- 【Java】对象、类(抽象类与内部类)、接口
博文内容概况 对象和类 抽象类 接口 内部类 对象和类 对象是对客观事物的抽象,类是对对象的抽象.类是一种数据类型,其外观和行为由用户定义.类中可以设置两种类型的元素:字段(有时被称为数据成员)和方法 ...
- jquery 筛选元素(1)
.eq() 减少匹配元素的集合为指定的索引的那一个元素. .eq(index) index一个整数,指示元素的位置,以0为基数. $("li").eq(2).css('backgr ...
- Map the Debris -freecodecamp算法题目
Map the Debris 1.要求 返回一个数组,其内容是把原数组中对应元素的平均海拔转换成其对应的轨道周期. 原数组中会包含格式化的对象内容,像这样 {name: 'name', avgAlt: ...