python内置数据结构之str-12064120
>>> s1"i'm \t a spuer student."
>>> s1.split() # 默认为空白字符(包括\t)
["i'm", 'a', 'spuer', 'student.']
>>> s1.split(sep='\t')
["i'm ", ' a spuer student.']
>>> s1.split(sep='s')
["i'm \t a ", 'puer ', 'tudent.']
>>> s1.split(sep='s',maxsplit=1)
["i'm \t a ", 'puer student.']
>>> s1.split(sep='s',maxsplit=2)
["i'm \t a ", 'puer ', 'tudent.']
>>> s1.split(sep='s',maxsplit=3)
["i'm \t a ", 'puer ', 'tudent.']
>>> s1.split(sep='s',maxsplit=-2) # 次数范围不合法,默认同-1
["i'm \t a ", 'puer ', 'tudent.']
页:
[1]