【python】字符串连接错误,类型错误 TypeError: coercing to Unicode

TypeError: coercing to Unicode: need string or buffer, list found

python用+做字符串连接时,出现了上述报错。检查后发现其中一个变量数据类型为list,是下面这种形式:

[u'This is the string i want to use']

主要是由于在返回值时得到了一个单个元素的list,将字符串作为了list处理。这是需要在变量后将这个字符串读出即可相加连接。


在这里插入图片描述
pic from pexels.com

原文地址:https://www.cnblogs.com/Tom-Ren/p/11054664.html