ReferenceString methods
str.splitlines()
Breaks text into lines, without the trailing empty piece split("\n") leaves.
Signature
text.splitlines(keepends=False)Parameters
| Name | Means |
|---|---|
keepends | keep the line breaks when True |
Returns
A list of strings.
Example
Python
text = "Ada\nGrace\n"
print(text.splitlines())
print(text.split("\n"))Output
['Ada', 'Grace'] ['Ada', 'Grace', '']