在练习格式化输出时出现错误TypeError: can't multiply sequence by non-int of type 'float'

为什么会出现TypeError:不能将序列乘以’float’类型的非整数?

实际情况是,这里隐藏着一个优先级的问题

我们发现一般情况下我们在格式化输出的%后面给只一个值时没有任何问题

但一旦%后面给的是一个数学运算式时,就要注意了!!!(字符串*float是无法输出的)

 '%.2f' % 2会作为一个格式化字符串先输出,然后再会*2——所以才出现上图的2.002.00这样重复的结果,但是如果给个*0.3就没有意义了

解决方法:(改正输出优先级)

												

报错处理TypeError: can't multiply sequence by non-int of type 'float'的更多相关文章

  1. vue项目使用echarts按需引入实现地图动态显示效果时,报错:TypeError: Cannot read property 'dataToPoint' of undefined

    vue项目使用echarts按需引入实现地图动态显示效果时,报错:TypeError: Cannot read property 'dataToPoint' of undefined 借鉴了该大神的文 ...

  2. jquery3.1.1报错Uncaught TypeError: a.indexOf is not a function

    jquery3.1.1报错Uncaught TypeError: a.indexOf is not a function 使用1.9就没有问题,解决办法: 就是把写的代码中: $(window).lo ...

  3. python中读取json文件报错,TypeError:the Json object must be str, bytes or bytearray,not ‘TextIOWrapper’

    利用python中的json读取json文件时,因为错误使用了相应的方法导致报错:TypeError:the Json object must be str, bytes or bytearray,n ...

  4. 导入json文件报错,TypeError expected string or buffer

    导入json文件报错,TypeError expected string or buffer 原因:用字符串赋值后,python会把双引号转换为单引号 import json data = [{&qu ...

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

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

  6. Appium 1.9.1 启动报错 Fatal TypeError: Class constructor BaseDriver cannot be invoked without 'new'

    安装了appium 1.9.1后一直报错Fatal TypeError: Class constructor BaseDriver cannot be invoked without 'new',无法 ...

  7. jQuery3.0+报错Uncaught TypeError: e.indexOf is not a function

    jQuery3.0+报错Uncaught TypeError: e.indexOf is not a function 使用.load()绑定事件时报错,Uncaught TypeError: e.i ...

  8. for遍历用例数据时,报错:TypeError: list indices must be integers, not dict,'int' object is not iterable解决方法

    一:报错:TypeError: list indices must be integers, not dict for i in range(0,len(test_data)): suite.addT ...

  9. faster rcnn报错:TypeError: slice indices must be integers or None or have an __index__ method

    https://blog.csdn.net/qq_27637315/article/details/78849756 https://blog.csdn.net/qq_21089969/article ...

  10. 2023-03-01 react-native 实现 复制功能 @react-native-community/clipboard 报错:TypeError: null is not an object (evaluating 'NativeClipboard_1.default.setString')。

    我的react-native(下称rn)版本为0.68,要实现这个功能主要用到rn的clipboard,在21年的时候他就已经提示clipboard会在未来的版本中上去掉,官方的建议是不要再从reac ...

随机推荐

  1. TypeScript – Decorator 装饰器

    前言 TypeScript 5.0 之后就可以使用正真的 JS Decorator 了, 从前 experiment 的版本依然可用, 但是不建议继续用, 因为差很远, 一起用会混乱. Decorat ...

  2. DOM – Browser Reflow & Repaint

    前言 没有深入研究过, 懂个概念就好, 等性能遇到问题在来看看. 以前写的笔记: 游览器 reflow 参考: reflow和repaint引发的性能问题 精读<web reflow> R ...

  3. Google Analytics & Ads 学习笔记

    更新: 2021-09-13 Naming conversion for event category, action, label https://support.google.com/analyt ...

  4. Azure 学习笔记

    选择 VM 配套 https://docs.azure.cn/zh-cn/virtual-machines/sizes  https://docs.azure.cn/zh-cn/virtual-mac ...

  5. ASP.NET Core – Filter

    介绍 Filter 类似 Middleware,只是它集中在处理 request 的前后, 站 MVC 角度看就是 before 和 after action, 站 Razor Pages 角度就是 ...

  6. Ubuntu 64系统编译android arm64-v8a 的openssl静态库libssl.a和libcrypto.a

    #!/bin/bash # Cross-compile environment for Android on ARM64 and x86 # # Contents licensed under the ...

  7. Servlet——Request对象-请求数据&请求参数

    Request 继承体系      1.Tomcat需要解析请求数据,封装为request对象,并且创建request对象传递到service方法中   2.使用request对象,查阅javaEE ...

  8. 我是如何开发一款支持IDEA、PyCharm、Android Sutdio 等JB全家桶的摸鱼插件的

    公众号「古时的风筝」,专注于后端技术,尤其是 Java 及周边生态. 个人博客:www.moonkite.cn 大家好,我是风筝 前些天做了一款支持 Jetbrains 大部分 IDE 的摸鱼插件- ...

  9. Android复习(三)清单文件中的元素

    <action> 向 Intent 过滤器添加操作. <activity> 声明 Activity 组件. <activity-alias> 声明 Activity ...

  10. mysql+navicat+eclipse+jsp

    mysql server 5.5安装 微信公众号搜软件智库,然后找到mysql 5.5 百度网盘下载对应自己电脑版本的mysql 百度网盘:http://pan.baidu.com/s/1jI5oB6 ...