Python-字符串分割

来源:互联网 发布:软件开发报告 编辑:程序博客网 时间:2024/06/11 20:44

要点

  • split()

示例

>>> s'abcabdcef'>>> s.split('c')['ab', 'abd', 'ef']>>> 

pydoc

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.split(s, sep=None, maxsplit=-1)    split(s [,sep [,maxsplit]]) -> list of strings    Return a list of the words in the string s, using sep as the    delimiter string.  If maxsplit is given, splits at no more than    maxsplit places (resulting in at most maxsplit+1 words).  If sep    is not specified or is None, any whitespace string is a separator.    (split and splitfields are synonymous)splitfields = split(s, sep=None, maxsplit=-1)    split(s [,sep [,maxsplit]]) -> list of strings    Return a list of the words in the string s, using sep as the    delimiter string.  If maxsplit is given, splits at no more than    maxsplit places (resulting in at most maxsplit+1 words).  If sep    is not specified or is None, any whitespace string is a separator.    (split and splitfields are synonymous)
0 0
原创粉丝点击