Python 练习实例33

Python 编程100例Python 编程100例

题目:按逗号分隔列表。

程序分析:无。

实例(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

Python 编程100例Python 编程100例

Python 练习实例34 Python 100例 题目:练习函数调用。 程序分析:使用函数,输出三次 RUNOOB 字符串。 实例 [mycode3 type='python'] #!/usr/bin/python # -*- coding: UTF-8 -*- def hello_runoob(): print ('RUNOOB') def hello_runoo..