报错处理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 ...
随机推荐
- 【爬虫实战】——利用bs4和正则表达式,简单实现爬取数据
前言 好久没有写博客了,由于一直比较忙,感觉快荒废了学习的步伐,最近由于需要利用爬虫爬取数据,总结一下,以便以后查阅. 目录 一.bs4的安装 二.bs4解析器 三.定位查找标签 四.转换格式 五.提 ...
- 【Python后端开发】Flask之ORM数据库操作
一.前言 ORM 对象映射关系程序. 通过orm将编程语言的对象模型和数据库的关系模型建立映射关系,这样我们在使用编程语言对数据库进行操作的时候可以直接使用编程语言的对象模型进行操作就可以了,而不用直 ...
- C++ STL vector 性能之push_back、emplace_back、reserve
#include <iostream> #include <vector> #include <chrono> using namespace std; const ...
- c程序设计语言 by K&R(四)输入与输出
一.标准输入.输出 1. 简单的输入\输出机制 从标准输入中一次读取一个字符:int getchar(void) 将字符c送到标准输出中: int putchar(int) 2. 输入重定向 如果程序 ...
- CSS & JS Effect – Tooltip
介绍 Tooltip 长这样 它用 popup 的方式来详细描述一个主体. 比如某个 icon 代表着什么. 参考 YouTube – How To Make Tooltips With Only C ...
- Web核心
JavaWeb 技术栈
- [namespace hdk] ordered_vector
功能: 已重载[]运算符 已重载+运算符(合并) 已重载+=运算符 已重载构造函数 clear() it() 以std::vector形式返回自身 print(char=' ',char='\n') ...
- 【赵渝强老师】使用Weblogic的WLST工具
一.什么是Weblogic WLST? WebLogic 脚本工具 (WebLogic Scripting Tool , WLST) 是一种命令行脚本界面,系统管理员和操作员用它来监视和管理 WebL ...
- 使用rancher cli对接k8s
一.获得rancher的token 1.进入rancher,点击右上角弹出框的ApI&Keys 2.进入页面后选择添加key 3.注意,这里的作用集群范围必须不能指定,否则在jenkins服务 ...
- jenkins + sonar 实现代码检测的配置
一.首先安装sonar scanner的客户端 我的jenkins版本为2.176.2 安装sonar需要安装客户端和服务端,这里只讲述客户端的相关配置.安装步骤省略 二.然后配置sonar scan ...