Python String သည် endswith() နည်းလမ်း
ဥပမာ
စာကြောင်းသည် သတ်ပုံလက္ခဏာ (.) ဖြင့်အဆုံးသတ်ခြင်းရှိမရှိ စစ်ဆေးပါ။
txt = "Hello, welcome to my world."
x = txt.endswith(".")
print(x)
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
endswith()
string သည် သတ်မှတ်ထားသောတန်ဖိုးဖြင့် အဆုံးသတ်ပါက၊ သို့မဟုတ် မဟုတ်ပါက False ဟူသော နည်းလမ်းသည် True ပြန်ပေးသည်။
အထားအသို
string.endswith(value, start, end)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
value | Required. The value to check if the string ends with |
start | Optional. An Integer specifying at which position to start the search |
end | Optional. An Integer specifying at which position to end the search |
နောက်ထပ် ဥပမာများ
ဥပမာ
စာကြောင်းက "ငါ့ကမ္ဘာ" ဟူသော စကားစုဖြင့် အဆုံးရှိမရှိ စစ်ဆေးပါ။
txt = "Hello, welcome to my world."
x = txt.endswith("my world.")
print(x)
ဥပမာ
ရာထူး 5 မှ 11 သည် "my world" ဟူသော စကားစုနှင့် အဆုံးရှိမရှိ စစ်ဆေးပါ။
txt = "Hello, welcome to my world."
x = txt.endswith("my world.",
5, 11)
print(x)