Python列表list转字符串报错:expected str instance, int found

Posted zhangphil

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python列表list转字符串报错:expected str instance, int found相关的知识,希望对你有一定的参考价值。

Python列表list转字符串报错:expected str instance, int found

代码中定义了一个字符串:

alist=[1,2,3,4,5]

结果''.join(alist)报错(因为列表中数据为整型),

expected str instance, int found

解决方法:

''.join(str(alist))

以上是关于Python列表list转字符串报错:expected str instance, int found的主要内容,如果未能解决你的问题,请参考以下文章