解决Python 异常TypeError: cannot concatenate 'str' and 'int' objects


Posted in Python onApril 08, 2020

TypeError: cannot concatenate 'str' and 'int' objects

print str + int 的时候就会这样了

python + 作为连接符的时候,不会自动给你把int转换成str

补充知识:TypeError: cannot concatenate 'str' and 'list' objects和Python读取和保存图片

解决Python 异常TypeError: cannot concatenate 'str' and 'int' objects

运行程序时报错,然后我将list转化为str就好了。

解决Python 异常TypeError: cannot concatenate 'str' and 'int' objects

利用''.join(list)

如果需要用逗号隔开,如1,2,3,4则使用','.join(list)

解决Python 异常TypeError: cannot concatenate 'str' and 'int' objects

Python中plt可以显示和保存图片,不能使用mping

import matplotlib.image as mpimg # mpimg 用于读取图片

开头import时加入

import matplotlib.pyplot as plt

from PIL import Image

打开用open('路径')

保存用a.save('路径')

以上这篇解决Python 异常TypeError: cannot concatenate 'str' and 'int' objects就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

Python 相关文章推荐
Python使用cx_Oracle模块将oracle中数据导出到csv文件的方法
May 16 Python
Python列表list内建函数用法实例分析【insert、remove、index、pop等】
Jul 24 Python
python机器学习之神经网络(一)
Dec 20 Python
matplotlib绘制动画代码示例
Jan 02 Python
Django权限机制实现代码详解
Feb 05 Python
python实现单向链表详解
Feb 08 Python
Python3直接爬取图片URL并保存示例
Dec 18 Python
Python3 获取文件属性的方式(时间、大小等)
Mar 12 Python
对django 2.x版本中models.ForeignKey()外键说明介绍
Mar 30 Python
Python使用paramiko连接远程服务器执行Shell命令的实现
Mar 04 Python
详解Python魔法方法之描述符类
May 26 Python
讲解Python实例练习逆序输出字符串
May 06 Python
TensorFlow2.1.0安装过程中setuptools、wrapt等相关错误指南
Apr 08 #Python
解决windows下python3使用multiprocessing.Pool出现的问题
Apr 08 #Python
python操作yaml说明
Apr 08 #Python
python 在右键菜单中加入复制目标文件的有效存放路径(单斜杠或者双反斜杠)
Apr 08 #Python
python将音频进行变速的操作方法
Apr 08 #Python
Python读取配置文件(config.ini)以及写入配置文件
Apr 08 #Python
Ubuntu18.04安装 PyCharm并使用 Anaconda 管理的Python环境
Apr 08 #Python
You might like
使用php shell命令合并图片的代码
2011/06/23 PHP
PHP中file_exists使用中遇到的问题小结
2016/04/05 PHP
关于ThinkPhp 框架表单验证及ajax验证问题
2017/07/19 PHP
Auntion-TableSort国人写的一个javascript表格排序的东西
2007/11/12 Javascript
hover的用法及live的用法介绍(鼠标悬停效果)
2013/03/29 Javascript
关于IE中getElementsByClassName不能用的问题解决方法
2013/08/26 Javascript
js定时器的使用(实例讲解)
2014/01/06 Javascript
详解Bootstrap四种图片样式
2016/01/04 Javascript
通过隐藏iframe实现无刷新上传文件操作
2016/03/16 Javascript
JQuery之proxy实现绑定代理方法
2016/08/01 Javascript
基于node.js制作简单爬虫教程
2017/06/29 Javascript
vue中进入详情页记住滚动位置的方法(keep-alive)
2018/09/21 Javascript
javascript面向对象三大特征之继承实例详解
2019/07/24 Javascript
原生js实现3D轮播图
2020/03/21 Javascript
Angular8引入百度Echarts进行图表分析的实现代码
2019/11/27 Javascript
ESLint 是如何检查 .vue 文件的
2020/11/30 Vue.js
Vue如何跨组件传递Slot的实现
2020/12/14 Vue.js
利用JS判断元素是否为数组的方法示例
2021/01/08 Javascript
5个很好的Python面试题问题答案及分析
2018/01/19 Python
Python装饰器(decorator)定义与用法详解
2018/02/09 Python
python在每个字符后添加空格的实例
2018/05/07 Python
解决pandas中读取中文名称的csv文件报错的问题
2018/07/04 Python
python 使用pandas计算累积求和的方法
2019/02/08 Python
django中使用Celery 布式任务队列过程详解
2019/07/29 Python
pygame实现俄罗斯方块游戏(AI篇2)
2019/10/29 Python
django 前端页面如何实现显示前N条数据
2020/03/16 Python
CSS3 清除浮动的方法示例
2018/06/01 HTML / CSS
使用CSS3实现input多选框自定义样式的方法示例
2019/07/19 HTML / CSS
浅谈html5增强的页面元素
2016/06/14 HTML / CSS
The Body Shop美体小铺西班牙官网:天然化妆品
2019/06/21 全球购物
某IT外企面试题-二分法求方程!看看大家的C++功底
2015/07/04 面试题
销售业务实习自我鉴定
2013/09/23 职场文书
军校制空专业毕业生自我鉴定
2013/11/16 职场文书
生育关怀行动实施方案
2014/03/26 职场文书
幼儿评语大全
2014/04/30 职场文书
Vertica集成Apache Hudi重磅使用指南
2022/03/31 Servers