社区
脚本语言
帖子详情
python3 TypeError: cannot concatenate 'str' and 'int' objects)
Rongz111
2018-05-18 08:41:19
刚刚参照《简明python教程》编了一个备份zip程序,为什么第8行会出现TypeError: cannot concatenate 'str' and 'int' objects)呢?
求大神解答下
...全文
1240
3
打赏
收藏
python3 TypeError: cannot concatenate 'str' and 'int' objects)
刚刚参照《简明python教程》编了一个备份zip程序,为什么第8行会出现TypeError: cannot concatenate 'str' and 'int' objects)呢? 求大神解答下
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
现在155不瘦20斤决不改名
2018-05-19
打赏
举报
回复
第7行是字符串组合,加方括号就是列表了呗,所以就类型错误了呗
Rongz111
2018-05-18
打赏
举报
回复
为什么去了就好了啊,第四行和第五行都是路径,为什么第五行不带方括号啊
混沌鳄鱼
2018-05-18
打赏
举报
回复
把第5行的方括号去掉
解决Python 异常
TypeError
: cannot
concat
e
nat
e
str
and
int
object
s
TypeError
: cannot
concat
e
nat
e ‘
str
’ and ‘
int
’
object
s pr
int
str
+
int
的时候就会这样了 python + 作为连接符的时候,不会自动给你把
int
转换成
str
补充知识:
TypeError
: cannot
concat
e
nat
e ‘
str
’ and ‘list’
object
s和Python读取和保存图片 运行程序时报错,然后我将list转化为
str
就好了。 利用”.join(list) 如果需要用逗号隔开,如1,2,3,4则使用’,’.join(list) Python中plt可以显示和保存图片,不能使用mping
解决Python 异常
TypeError
: cannot
concat
e
nat
e '
str
' and '
int
'
object
s
主要介绍了解决Python 异常
TypeError
: cannot
concat
e
nat
e '
str
' and '
int
'
object
s,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
解决Python中字符串和数字拼接报错的方法
前言 众所周知Python不像JS或者PHP这种弱类型语言里在字符串连接时会自动转换类型,如果直接将字符串和数字拼接会直接报错。 如以下的代码: # coding=utf8
str
= '你的分数是:' num = 82 text =
str
+num+'分 | 琼台博客' pr
int
text 执行结果 直接报错:
TypeError
: cannot
concat
e
nat
e ‘
str
’ and ‘
int
’
object
s 解决这个方法只有提前把num转换为字符串类型,可以使用bytes函数把
int
型转换为
str
ing型。 代码: # coding=utf8
str
= '你的分数是:' n
Python新手入门最容易犯的错误总结
主要总结了一些关于Python新手入门最容易犯的错误,希望通过学习本文总结的十二点易犯错误点,能够给新手们带来一定的帮助,需要的朋友可以参考学习,下面来一起看看吧。
python cannot
concat
e
nat
e_解决Python 异常
TypeError
: cannot
concat
e
nat
e '
str
' and '
int
'
object
s
解决Python 异常
TypeError
: cannot
concat
e
nat
e '
str
' and '
int
'
object
s
TypeError
: cannot
concat
e
nat
e '
str
' and '
int
'
object
spr
int
str
+
int
的时候就会这样了python + 作为连接符的时候,不会自动给你把
int
转换成
str
补充知识:
TypeError
: cannot co...
脚本语言
37,744
社区成员
34,212
社区内容
发帖
与我相关
我的任务
脚本语言
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
复制链接
扫一扫
分享
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
试试用AI创作助手写篇文章吧
+ 用AI写文章