Python String rsplit() နည်းလမ်း
ဥပမာ
ကော်မာကို အသုံးပြု၍ စာရင်းတစ်ခုသို့ စာကြောင်းတစ်ခု ခွဲကာ ခြားနားချက်အဖြစ် space (, ) ဖြင့် နောက်တွင်-
txt = "apple, banana, cherry"
x = txt.rsplit(", ")
print(x)
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
နည်းလမ်း သည် rsplit()
ညာဘက်မှစပြီး string တစ်ခုကို စာရင်းတစ်ခုအဖြစ် ပိုင်းခြားသည်။
"max" ကို မသတ်မှတ်ထားပါက၊ ဤနည်းလမ်းသည် နည်းလမ်းအတိုင်း ပြန်သွားပါမည်
split()
။
မှတ်ချက် ။ _ _
အထားအသို
string.rsplit(separator, maxsplit)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
separator | Optional. Specifies the separator to use when splitting the string. By default any whitespace is a separator |
maxsplit | Optional. Specifies how many splits to do. Default value is -1, which is "all occurrences" |
နောက်ထပ် ဥပမာများ
ဥပမာ
အများဆုံး 2 ခုပါရှိသော string ကို စာရင်းတစ်ခုသို့ ခွဲပါ-
txt = "apple, banana, cherry"
# setting the maxsplit parameter
to 1, will return a list with 2 elements!
x = txt.rsplit(", ", 1)
print(x)