mirror of
https://github.com/python/cpython.git
synced 2025-08-28 04:35:02 +00:00
Add rsplit method for str and unicode builtin types.
SF feature request #801847. Original patch is written by Sean Reifschneider.
This commit is contained in:
parent
dce391cb39
commit
3ae811b57d
7 changed files with 402 additions and 1 deletions
|
@ -121,6 +121,18 @@ def split(s, sep=None, maxsplit=-1):
|
|||
return s.split(sep, maxsplit)
|
||||
splitfields = split
|
||||
|
||||
# Split a string into a list of space/tab-separated words
|
||||
def rsplit(s, sep=None, maxsplit=-1):
|
||||
"""rsplit(s [,sep [,maxsplit]]) -> list of strings
|
||||
|
||||
Return a list of the words in the string s, using sep as the
|
||||
delimiter string, starting at the end of the string and working
|
||||
to the front. If maxsplit is given, at most maxsplit splits are
|
||||
done. If sep is not specified or is None, any whitespace string
|
||||
is a separator.
|
||||
"""
|
||||
return s.rsplit(sep, maxsplit)
|
||||
|
||||
# Join fields with optional separator
|
||||
def join(words, sep = ' '):
|
||||
"""join(list [,sep]) -> string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue