TypeError: Can't convert 'int' object to str implicitly

L=[1,2,3]
print("第一个元素是:" +L[0] )

报错:TypeError:不能将int转化成 str

TypeError: Can't convert 'int' object to str implicitly_第1张图片
原因:输出的内容为:Str+int 的拼接
解决办法:
把int类型 L[0] 强制变为str(L[0])

你可能感兴趣的:(python,TypeError,Cant,conve)