Latest web development tutorials

Python 練習實例33

Python 100例 Python 100例

題目:按逗號分隔列表。

程序分析:無。

程序源代碼:

#!/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

Python 100例 Python 100例