mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	Merge #15554: clarify splitlines/split differences.
Patch by Chris Jerdonek.
This commit is contained in:
		
						commit
						638de338e6
					
				
					 1 changed files with 8 additions and 5 deletions
				
			
		| 
						 | 
					@ -1351,16 +1351,19 @@ functions based on regular expressions.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. method:: str.splitlines([keepends])
 | 
					.. method:: str.splitlines([keepends])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   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.
 | 
				
			||||||
   breaks are not included in the resulting list unless *keepends* is given and
 | 
					   This method uses the universal newlines approach to splitting lines.
 | 
				
			||||||
   true. This method uses the universal newlines approach to splitting lines.
 | 
					   Line breaks are not included in the resulting list unless *keepends* is
 | 
				
			||||||
   Unlike :meth:`~str.split`, if the string ends with line boundary characters
 | 
					   given and true.
 | 
				
			||||||
   the returned list does ``not`` have an empty last element.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
   For example, ``'ab c\n\nde fg\rkl\r\n'.splitlines()`` returns
 | 
					   For example, ``'ab c\n\nde fg\rkl\r\n'.splitlines()`` returns
 | 
				
			||||||
   ``['ab c', '', 'de fg', 'kl']``, while the same call with ``splitlines(True)``
 | 
					   ``['ab c', '', 'de fg', 'kl']``, while the same call with ``splitlines(True)``
 | 
				
			||||||
   returns ``['ab c\n', '\n, 'de fg\r', 'kl\r\n']``.
 | 
					   returns ``['ab c\n', '\n, 'de fg\r', 'kl\r\n']``.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Unlike :meth:`~str.split` when a delimiter string *sep* is given, this
 | 
				
			||||||
 | 
					   method returns an empty list for the empty string, and a terminal line
 | 
				
			||||||
 | 
					   break does not result in an extra line.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. method:: str.startswith(prefix[, start[, end]])
 | 
					.. method:: str.startswith(prefix[, start[, end]])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue