Python-Übungsbeispiel 33

Python 100例Python 100 Beispiele

Frage:Eine Liste durch Kommas trennen.

Programmanalyse:Keine.

Beispiel (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)

Die Ausgabe des obigen Beispiels ist:

1,2,3,4,5

Python 100例Python 100 Beispiele

Andere Erweiterungen