Python String splitlines() Metode
Voorbeeld
Verdeel 'n string in 'n lys waar elke reël 'n lysitem is:
txt = "Thank
you for the music\nWelcome to the jungle"
x = txt.splitlines()
print(x)
Definisie en gebruik
Die splitlines()
metode verdeel 'n string in 'n lys. Die splitsing word by lynbreuke gedoen.
Sintaksis
string.splitlines(keeplinebreaks)
Parameterwaardes
Parameter | Description |
---|---|
keeplinebreaks | Optional. Specifies if the line breaks should be included (True), or not
(False). Default value is False |
Meer voorbeelde
Voorbeeld
Verdeel die tou, maar hou die lynbreuke:
txt = "Thank
you for the music\nWelcome to the jungle"
x = txt.splitlines(True)
print(x)