पायथन स्ट्रिंग शुरू होता है () विधि
उदाहरण
जांचें कि क्या स्ट्रिंग "हैलो" से शुरू होती है:
txt = "Hello, welcome to my world."
x = txt.startswith("Hello")
print(x)
परिभाषा और उपयोग
यदि startswith()
स्ट्रिंग निर्दिष्ट मान से शुरू होती है, तो विधि सही है, अन्यथा गलत है।
वाक्य - विन्यास
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 "स्वागत" वर्णों से शुरू होती है:
txt = "Hello, welcome to my world."
x = txt.startswith("wel",
7, 20)
print(x)