Python编程之按逗号分隔列表

版权声明:此篇博文为博主心血o(╥﹏╥)o,如要转载请注明来源,勿忘心安! https://blog.csdn.net/dyq1995/article/details/88813782

问题描述:按逗号分隔一个列表。

程序分析:列表的格式输出。

源代码:


#!/usr/bin/python
# -*- coding: UTF-8 -*-
 
L = [10,20,30,40,50]
s1 = ','.join(str(n) for n in L)
print s1

输出结果如下:

10,20,30,40,50

猜你喜欢

转载自blog.csdn.net/dyq1995/article/details/88813782