1 n = input()
2 if n>=100:print(int(n)/10)
3 else:print(int(n)*10)

报错内容:

Traceback (most recent call last):File "1.py", line 12, in <module>if n>=100:print(int(n)/10)
TypeError: '>=' not supported between instances of 'str' and 'int'***Repl Closed***

分析:input()返回的数据类型是str,不能直接和整数进行比较,必须先把str换成整数,使用int()方法

          因此,将input变量转换为int型即可。

1 n = input()
2 n = int(n)
3 if n>=100:print(int(n)/10)
4 else:print(int(n)*10)

或者:

1 n = int(input("Input a number:"))
2 if n>=100:print(int(n)/10)
3 else:print(int(n)*10)

执行Python提示《not supported between instances of str and int》相关推荐

  1. ‘<’ not supported between instances of ‘str’ and ‘int’

    '<' not supported between instances of 'str' and 'int' python 中 字符串 和 整形 进行比较之后 出现的报错信息. python 中 ...

  2. 【已解决】TypeError: ‘<‘ not supported between instances of ‘str‘ and ‘int‘_Python系列学习笔记

    TypeError: '<' not supported between instances of 'str' and 'int' 翻译:str类型无法与int类型比较 解决:将<两侧类型 ...

  3. 成功解决TypeError: ‘<‘ not supported between instances of ‘str‘ and ‘int‘

    成功解决TypeError: '<' not supported between instances of 'str' and 'int' 目录 解决问题 解决思路 解决方法 解决问题 Type ...

  4. TypeError: not supported between instances of str and int【python3】

    python3报错:TypeError: '>' not supported between instances of 'str' and 'int' **报错原因:**int类型没有转换为st ...

  5. 提示错误“'=' not supported between instances of 'range' and 'int'”

    在学习<Designing Machine Learning Systems with Python>(中文名<机器学习系统设计--python语言实现>)一书中,第三章第二节 ...

  6. 成功解决极其刁钻bug之TypeError: ‘<=‘ not supported between instances of ‘list‘ and ‘int‘

    成功解决极其刁钻bug之TypeError: '<=' not supported between instances of 'list' and 'int' 目录 解决问题 解决思路 解决方法 ...

  7. not supported between instances of 'SafeText' and 'int' 问题出现以及解决

    1.今天更新完代码,突然间报了这个错误:'<' not supported between instances of 'SafeText' and 'int' 2.主要代码如下,其中是最后一行报 ...

  8. java执行python提示import os找不到_java利用Jython调用python抛出错误ImportError: No module named odbchelper...

    Python代码: import odbchelper def add(x, y): """ add method """ return x ...

  9. python运行报错TypeError: cannot concatenate 'str' and 'int' objects

    dict运行报错 d = {     'Adam': 95,     'Lisa': 85,     'Bart': 59 } for key in d:     print key+":& ...

最新文章

  1. html概述和基本结构
  2. 图文讲解,团队开发中的 Git 最佳实践
  3. 浅谈Spark应用程序的性能调优
  4. java如何读取下拉列表的值_java - 如何在Selenium 2中选择/获取下拉选项
  5. python循环遍历所有目录_python 遍历文件夹
  6. leetcode 40. 组合总和 II 思考分析
  7. JavaScript笔记-对wheelDeltaY和deltaY的体会
  8. BZOJ3376: [Usaco2004 Open]Cube Stacking 方块游戏
  9. HDU-1159-Common Subsequence
  10. 学习windows内核一
  11. virtualbox vm 虚拟机 迁移
  12. deepstream多路rtsp流,避免相互影响
  13. python错误提示未定义tn_未找到Python方法,但在类中定义
  14. 用java模拟csma_CSMA/CD仿真的过程
  15. VC6.0 快捷键整理
  16. Excel中怎么把经纬度记录转成经纬度数值形式
  17. 中国互联网20周年谈----GITC 2014
  18. 再读德鲁克#2 如何提升生产率
  19. 干货 | Elasticsearch 8.X 节点角色划分深入详解
  20. Docker Desktop(WSL2)修改镜像存储位置

热门文章

  1. H.266之CABAC
  2. 10--File类字节流异常
  3. arduino uno r3单片机封装图_Arduino和单片机区别,及Arduino入门教程
  4. python基础--面向对象(一)
  5. [转贴]我孙子.........笑死我了
  6. 给你一个登录页面,你该如何做渗透测试呢?
  7. pdf文件里面水印如何全部去掉
  8. pycharm关联github
  9. 使用JAF创建MIME消息
  10. 电脑为什么不能运行php文件路径,window_windows系统下英雄联盟不能启动 指定路径不存在的解决办法,小编把英雄联盟从别人电脑里 - phpStudy...