पायथन स्ट्रिंग स्प्लिटलाइन () विधि
उदाहरण
एक स्ट्रिंग को एक सूची में विभाजित करें जहां प्रत्येक पंक्ति एक सूची आइटम है:
txt = "Thank
you for the music\nWelcome to the jungle"
x = txt.splitlines()
print(x)
परिभाषा और उपयोग
splitlines()
विधि एक स्ट्रिंग को एक सूची में विभाजित करती है । विभाजन लाइन ब्रेक पर किया जाता है।
वाक्य - विन्यास
string.splitlines(keeplinebreaks)
पैरामीटर मान
Parameter | Description |
---|---|
keeplinebreaks | Optional. Specifies if the line breaks should be included (True), or not
(False). Default value is False |
और ज्यादा उदाहरण
उदाहरण
स्ट्रिंग को विभाजित करें, लेकिन लाइन ब्रेक रखें:
txt = "Thank
you for the music\nWelcome to the jungle"
x = txt.splitlines(True)
print(x)