报错处理TypeError: can't multiply sequence by non-int of type 'float'

在练习格式化输出时出现错误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'的更多相关文章
- vue项目使用echarts按需引入实现地图动态显示效果时,报错:TypeError: Cannot read property 'dataToPoint' of undefined
vue项目使用echarts按需引入实现地图动态显示效果时,报错:TypeError: Cannot read property 'dataToPoint' of undefined 借鉴了该大神的文 ...
- 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 ...
- 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 ...
- 导入json文件报错,TypeError expected string or buffer
导入json文件报错,TypeError expected string or buffer 原因:用字符串赋值后,python会把双引号转换为单引号 import json data = [{&qu ...
- input()报错:TypeError: '>=' not supported between instances of 'str' and 'int'
今天学习python基础—分支与循环,接触到了if.在练习一个if语句的时候,出现了错误. 题目是: 根据分数划分成四个级别:优秀.良好.及格.不及格,分数是72: grade = 72if grad ...
- 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',无法 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- Selenium 操作已打开的浏览器
偶尔要用到,start writing 实现步骤 先启动 Chrome,打开任务管理器,找到 chrome.exe,地址栏输入 cmd,然后执行 chrome.exe --remote-debuggi ...
- 将文件的换行符由 CRLF 转换为 LF
在 DOS/Windows 文本文件中,换行,也称为新行,是两个字符的组合:回车(CR)后跟一个换行(LF).在 Unix 文本文件中,一行的换行是单个字符:换行(LF).在 Mac 文本文件中,在 ...
- android 访问域名接口报错
1. 移动端访问https域名及接口,显示 java.net.UnknownHostException: Unable to resolve host "xxx" : No add ...
- ES6中的Set数据结构
Set是ES6新推出的数据结构,Set结构里面的每个元素都是唯一的: 如何创建一个Set? // Set 构造函数接收一个数组进行初始化;如果什么都不传则创建一个空Set; var set = new ...
- CSS & JS Effect – FAQ Accordion & Slide Down
效果 参考: Youtube – Responsive FAQ accordion dropdown | HTML and CSS Tutorial 几个难点 1. 如何 align left for ...
- C++ STL stack容器——栈
stack容器 基本概念 stack是一种先进后出的数据结构,它只有一个出口,形式如下图所示.stack容器允许新增元素,移除元素,取得栈顶元素,但是除了最顶端外,没有任何地方可以存取stack的娶她 ...
- Docker数据共享与持久化(六)
接下来介绍如何在 Docker 内部以及容器之间管理数据,在容器中管理数据主要有两种方式: 数据卷(Data Volumes) 挂载主机目录 (Bind mounts) 一.数据卷 数据卷是一个可供一 ...
- Linux工具:Winscp显示隐藏的文件
事件起因: 需要用Winscp上传文件到服务器,然后发现文件被隐藏了 解决办法: Winscp软件的快捷键 : Ctrl + Alt + HWindscp软件的设置方法: 菜单栏 选项 -> 面 ...
- 一款基于Uniapp开发的开源低代码平台
rtvue-lowcode低代码开发平台 rtvue-lowcode一款基于uniapp框架和uview组件库的低代码开发平台,项目提供可视化拖拽编辑器,采用MIT开源协议,适用于app.小程序等项目 ...
- springboot起步依赖
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot ...