Python String startswith() နည်းလမ်း
ဥပမာ
string သည် "Hello" ဖြင့် စတင်ခြင်း ရှိမရှိ စစ်ဆေးပါ-
txt = "Hello, welcome to my world."
x = txt.startswith("Hello")
print(x)
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
startswith()
string သည် သတ်မှတ်ထားသော တန်ဖိုးဖြင့် စတင်ပါက၊ သို့မဟုတ် မဟုတ်ပါက False ဟူသော နည်းလမ်းသည် True ပြန်ပေးသည်။
အထားအသို
string.startswith(value, start, end)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
value | Required. The value to check if the string starts 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 |
နောက်ထပ် ဥပမာများ
ဥပမာ
ရာထူး 7 မှ 20 သည် "wel" စာလုံးဖြင့် စတင်ခြင်းရှိမရှိ စစ်ဆေးပါ။
txt = "Hello, welcome to my world."
x = txt.startswith("wel",
7, 20)
print(x)