Python中使用.join()连接list时,出现类型错误的解决办法:
>>> ls = [1,2,3] >>> print ','.join(ls) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: sequence item 0: expected string, int found
解决办法:
对list中的元素进行类型转换到string
>>> print ','.join('%s' % id for id in ls) 1,2,3