Python String rstrip() နည်းလမ်း
ဥပမာ
စာကြောင်း၏အဆုံးတွင် အဖြူရောင်နေရာလွတ်များကို ဖယ်ရှားပါ-
txt = " banana "
x =
txt.rstrip()
print("of all fruits", x, "is my favorite")
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
rstrip()
နည်းလမ်းသည် နောက်လိုက်နေသော စာလုံးများကို ဖယ်ရှားသည် (စာကြောင်း၏ အဆုံးတွင် စာလုံးများ)၊ space သည် ဖယ်ရှားရန် ပုံသေ နောက်ဆွဲဇာတ်ကောင်ဖြစ်သည် ။
အထားအသို
string.rstrip(characters)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
characters | Optional. A set of characters to remove as trailing characters |
နောက်ထပ် ဥပမာများ
ဥပမာ
ကော်မာ၊ s၊ q၊ သို့မဟုတ် w ဖြစ်ပါက နောက်မှလိုက်သော အက္ခရာများကို ဖယ်ရှားပါ-
txt = "banana,,,,,ssqqqww....."
x = txt.rstrip(",.qsw")
print(x)