错误内容:
can only concatenate str (not "int") to str
错误代码:
print("jianxieshi"+ c+ ".")

错误原因:
print 命令后引号内应该都是字符串 而不是变量
更正
print("jianxieshi"+ str(c)+ ".")
本文详细解析了Python中常见的类型拼接错误:尝试将整数与字符串进行拼接所导致的问题。通过一个具体示例,阐述了如何将变量转换为字符串类型,从而避免此类错误。适用于初学者和需要回顾基础概念的开发者。
错误内容:
can only concatenate str (not "int") to str
错误代码:
print("jianxieshi"+ c+ ".")

错误原因:
print 命令后引号内应该都是字符串 而不是变量
更正
print("jianxieshi"+ str(c)+ ".")
转载于:https://www.cnblogs.com/programmingnoob/p/11184548.html
294
363

被折叠的 条评论
为什么被折叠?