题目:按逗号分隔列表。

思路:将[1,2,3,4,5]转化为["1", "2", "3", "4", "5"],然后使用join()

实例(Python 2.0+)

#!/usr/bin/python

# -*- coding: UTF-8 -*-

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

s1 = ','.join(str(n) for n in L)

print s1

输出:1,2,3,4,5