Python String splitlines() နည်းလမ်း
ဥပမာ
စာကြောင်းတစ်ကြောင်းစီသည် စာရင်းအရာတစ်ခုပါရှိသော စာရင်းတစ်ခုသို့ စာကြောင်းတစ်ခု ခွဲလိုက်ပါ-
txt = "Thank
you for the music\nWelcome to the jungle"
x = txt.splitlines()
print(x)
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
နည်းလမ်း သည် splitlines()
စာကြောင်းတစ်ခုကို စာရင်းတစ်ခုအဖြစ် ပိုင်းခြားသည်။ လိုင်းခွဲခြင်းများ ပြုလုပ်ပါသည်။
အထားအသို
string.splitlines(keeplinebreaks)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
keeplinebreaks | Optional. Specifies if the line breaks should be included (True), or not
(False). Default value is False |
နောက်ထပ် ဥပမာများ
ဥပမာ
ကြိုးကို ခွဲပါ၊ သို့သော် မျဉ်းကြောင်းများကို ဆက်ထားပါ။
txt = "Thank
you for the music\nWelcome to the jungle"
x = txt.splitlines(True)
print(x)