报错:
TypeError: can only concatenate str (not “int”) to str
TypeError: unsupported operand type(s) for /: ‘str’ and 'str’

python代码部分~
正确代码:

a = int(input('你离开几小时(h):'))
b = int(input('你离开几分钟(min):'))
c = int(input('几秒钟循环一次(s):'))
m = a*60*60+b*60
s = (a*60*60+b*60)/c
print("全部的秒数为:",m)
print("次数为:",s)

最后的执行情况:

失败了好多次~
失败1:
所报错误:

Traceback (most recent call last):File "C:\Users\HWP\Desktop\1次.py", line 5, in <module>s = (a*60*60+b*60)/c
TypeError: unsupported operand type(s) for /: 'str' and 'str'

代码:

a = input('你离开几小时(h):')
b = input('你离开几分钟(min):')
c = input('几秒钟循环一次(s):')
m = a*60*60+b*60
s = (a*60*60+b*60)/c
print("全部的秒数为:"+m)
print("次数为:"+s)


因为:
正确的代码,把input的内容,转变为整数(或其它类型的数):

  1. a = int(input())
  2. a = float(input())
    前面再加一个字符类型~
#这个代码并不全部正确,因为输出那里有问题~失败2讲到啦~
a = int(input('你离开几小时(h):'))
b = int(input('你离开几分钟(min):'))
c = int(input('几秒钟循环一次(s):'))
m = a*60*60+b*60
s = (a*60*60+b*60)/c
print("全部的秒数为:"+m)
print("次数为:"+s)

失败2:
所报错误:

Traceback (most recent call last):File "C:\Users\HWP\Desktop\1次.py", line 6, in <module>print("全部的秒数为:"+m)
TypeError: can only concatenate str (not "int") to str

代码:

a = int(input('你离开几小时(h):'))
b = int(input('你离开几分钟(min):'))
c = int(input('几秒钟循环一次(s):'))
m = a*60*60+b*60
s = (a*60*60+b*60)/c
print("全部的秒数为:"+m)
print("次数为:",s)

就因为这一句:print(“全部的秒数为:”+m)

正确的代码是,

print("全部的秒数为:",m)

不能带+号#怪我以前看了错误教程

python unsupported operand type(s) for /: 'str' and 'str' can only concatenate str (not int) to s相关推荐

  1. 踩坑中:TypeError: unsupported operand type(s) for /: 'str' and 'int'

    在网上查看了很多博客,首先从报错提示来讲TypeError: unsupported operand type(s) for /: 'str' and 'int',明确了是类型错误:不支持操作类型为整 ...

  2. 成功解决ret = ret / rcountTypeError: unsupported operand type(s) for /: ‘str‘ and ‘int‘

    成功解决ret = ret / rcountTypeError: unsupported operand type(s) for /: 'str' and 'int' 目录 解决问题 解决思路 解决方 ...

  3. python报错TypeError: unsupported operand type(s) for -: ‘decimal.Decimal‘ and ‘float‘的解决方法

    问题描述 在编写python代码时,进行小数位相减时出现 TypeError: unsupported operand type(s) for -: 'decimal.Decimal' and 'fl ...

  4. 解决报错TypeError:unsupported operand type(s) for +: ‘NoneType‘ and ‘str‘

    文章目录 一.问题描述 二.解决方案 Reference 一.问题描述 from pyspark.sql.types import StringType@udf(returnType = String ...

  5. apex安装报错:TypeError: unsupported operand type(s) for +: ‘NoneType‘ and ‘str‘

    参考解决方法:TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' · Issue #990 · NVIDIA/apex ...

  6. Python PIP Install throws TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

    Python PIP Install throws TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

  7. 解决Python中sum函数出现的TypeError: unsupported operand type(s) for +: 'int' and 'list'错误问题

    当在Python中运行sum函数时,会出现"TypeError: unsupported operand type(s) for +: 'int' and 'list'"这样的问题 ...

  8. 解决pandas(Python)的报错:unsupported operand type(s) for -: ‘datetime.date’ and ‘Timestamp’

    在使用Pandas包的时候,遇到时间加减出现的报错 'datetime.date'是datetime的一种时间格式: 'Timestamp'(注意是大写的字母)是Pandas的一种时间格式. 这两个虽 ...

  9. Django问题:TypeError: unsupported operand type(s) for -: ‘str‘ and ‘float‘

    Django问题:TypeError: unsupported operand type(s) for -: 'str' and 'float Traceback (most recent call ...

最新文章

  1. DDoS攻击惯犯图鉴
  2. Designing Virtual Connect for vSphere 5.x
  3. mint java_Oracle Java 12 (JDK 12)在Ubuntu、Linux Mint或Debian(使用PPA)安装配置
  4. 本田思域自动挡的使用技巧
  5. python 日期格式打印_Python打印格式
  6. 阶段5 3.微服务项目【学成在线】_day01 搭建环境 CMS服务端开发_26-页面查询接口测试-Postman...
  7. 20天通过中级软件设计师攻略(附资料)
  8. 01将乌班图系统安装到U盘,实现即插即用
  9. ch341a烧录器zip_CH341A编程器
  10. Win10 锁屏自动息屏解决方案
  11. 群晖 NAS 中的 Audio Station 一直不能加载 NAS 中的音乐问题的解决方法及自定义音乐库文件夹方法.md
  12. 爬虫练习三:爬取链家二手房信息
  13. 带宽在计算机系统中的意义,带宽是什么意思?
  14. Centos 7 环境下将修改后的MAC地址永久保存
  15. PhpSpreadsheet读取excel
  16. 一个新手学着重装系统之路
  17. vue点击按钮打开新页签,并传参
  18. CommandArgument的一种用法
  19. python 董付国程序设计基础与应用第三版pdf_Python 程序设计基础(董付国 著)完整版PDF[6MB]...
  20. 健身软件的全球与中国市场2022-2028年:技术、参与者、趋势、市场规模及占有率研究报告

热门文章

  1. 掌握这些步骤,机器学习模型问题药到病除
  2. 开源!mathAI手写拍照自动能解高数题,还不快试试?
  3. 如何为回归问题选择最合适的机器学习方法?
  4. 何恺明等人提TensorMask框架:比肩Mask R-CNN,4D张量预测新突破
  5. 大家都收藏了的最新开源项目Top12!CV、NLP、机器学习一应俱全
  6. 复旦肖仰华:领域知识图谱落地实践中的问题与对策
  7. AI一分钟 | 马斯克:特斯拉内部有人故意搞破坏;亚马逊推出酒店定制版Alexa
  8. 不被邀请又怎样!马云都快买下中国AI芯片的半壁江山了,直怼腾讯和百度
  9. 代码规范+设计模式落地之路
  10. 微信8.0内测更新!!!(附内测体验资格)