mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
#14957: clarify splitlines docs.
Initial patch by Michael Driscoll, I added the example.
This commit is contained in:
parent
5e247b705e
commit
4fbf7c61fe
1 changed files with 7 additions and 1 deletions
|
@ -1185,7 +1185,13 @@ string functions based on regular expressions.
|
||||||
|
|
||||||
Return a list of the lines in the string, breaking at line boundaries. Line
|
Return a list of the lines in the string, breaking at line boundaries. Line
|
||||||
breaks are not included in the resulting list unless *keepends* is given and
|
breaks are not included in the resulting list unless *keepends* is given and
|
||||||
true.
|
true. This method uses the universal newlines approach to splitting lines.
|
||||||
|
Unlike :meth:`~str.split`, if the string ends with line boundary characters
|
||||||
|
the returned list does ``not`` have an empty last element.
|
||||||
|
|
||||||
|
For example, ``'ab c\n\nde fg\rkl\r\n'.splitlines()`` returns
|
||||||
|
``['ab c', '', 'de fg', 'kl']``, while the same call with ``splinelines(True)``
|
||||||
|
returns ``['ab c\n', '\n, 'de fg\r', 'kl\r\n']``.
|
||||||
|
|
||||||
|
|
||||||
.. method:: str.startswith(prefix[, start[, end]])
|
.. method:: str.startswith(prefix[, start[, end]])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue