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
ref : http://hi.baidu.com/zhumq92/item/3e58dd395c4b040dcfb9fe62