Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.

Link zu der Vergleichsansicht

Beide Seiten, vorherige ÜberarbeitungVorherige Überarbeitung
Nächste Überarbeitung
Vorherige Überarbeitung
meins:python:strings-und-print [Sunday, 05. Jun 2016 12:16] – [Formatter] Ivo Schwalbemeins:python:strings-und-print [Sunday, 05. Jun 2016 12:25] (aktuell) – [Formatter] Ivo Schwalbe
Zeile 46: Zeile 46:
 </code> </code>
  
-http://learnpythonthehardway.org/book/ex6.html+http://learnpythonthehardway.org/book/ex6.html\\ 
 +https://docs.python.org/3/tutorial/inputoutput.html#fancier-output-formatting (Neu!)\\
  
 <code python> <code python>
Zeile 76: Zeile 77:
 # print "Schnick" + 3 geht NICHT, weil string und int # print "Schnick" + 3 geht NICHT, weil string und int
 print w + e print w + e
 +</code>
 +
 +<code python>
 +# 10 Punkte
 +print "." * 10
 +</code>
 +
 +<code python>
 +# Format als string speichern
 +formatter = "%r %r %r %r"
 +
 +# Format mit verschiedenem Inhalt mischen
 +# Achtung: Geht nur mit %r, weil string, int (und float)
 +print formatter % (1, 2, 3, 4)
 +print formatter % ("one", "two", "three", "four")
 +print formatter % (True, False, False, True)
 +print formatter % (formatter, formatter, formatter, formatter)
 +print formatter % (
 +    "I had this thing.",
 +    "That you could type up right.",
 +    "But it didn't sing.",
 +    "So I said goodnight."
 +)
 </code> </code>