神剑山庄资源网 Design By www.hcban.com

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,TypeError,str,int

神剑山庄资源网 Design By www.hcban.com
神剑山庄资源网 免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
神剑山庄资源网 Design By www.hcban.com

评论“解决Python 异常TypeError: cannot concatenate 'str' and 'int' objects”

暂无解决Python 异常TypeError: cannot concatenate 'str' and 'int' objects的评论...