# splitlines()の使い方

Home String Methods

# splitlines()の例1

Split a string into a list where each line is a list item:

    txt = "Thank 
    you for the music\nWelcome to the jungle"x = txt.splitlines()
    print(x)

# splitlines()の定義と使い方

splitlines()関数は、文字列を とします。分割は改行時に行われます。

# splitlines()の構文

string.splitlines(keeplinebreaks)

# splitlines()の引数

パラメータ 説明

keeplinebreaks オプション. Specifies if the line breaks should be included (True), or not (False). Default value is not (False)

# splitlines()の例2

Split the string, but keep the line breaks:

    txt = "Thank 
    you for the music\nWelcome to the jungle"x = txt.splitlines(True)
    print(x)

Home String Methods