First page Back Continue Last page Overview Image

String in Zeilen zerlegen

>>> rhyme = "An apple a day\nSends the doctor away\n"

>>> rhyme.splitlines()

['An apple a day', 'Sends the doctor away']

>>> rhyme.splitlines(True)

['An apple a day\n', 'Sends the doctor away\n']

Zum Vergleich:

>>> rhyme.split("\n")

['An apple a day', 'Sends the doctor away', '']

>>> rhyme.split()

['An', 'apple', 'a', 'day', 'Sends', 'the', 'doctor', 'away']