Python String splitlines() Yöntemi
Örnek
Bir dizeyi, her satırın bir liste öğesi olduğu bir listeye bölün:
txt = "Thank
you for the music\nWelcome to the jungle"
x = txt.splitlines()
print(x)
Tanım ve Kullanım
Yöntem splitlines()
, bir dizeyi bir listeye böler. Bölme, satır sonlarında yapılır.
Sözdizimi
string.splitlines(keeplinebreaks)
Parametre Değerleri
Parameter | Description |
---|---|
keeplinebreaks | Optional. Specifies if the line breaks should be included (True), or not
(False). Default value is False |
Daha fazla örnek
Örnek
Dizeyi bölün, ancak satır sonlarını koruyun:
txt = "Thank
you for the music\nWelcome to the jungle"
x = txt.splitlines(True)
print(x)