Skip to content

#434 Python split() #9

@LiuL0703

Description

@LiuL0703

语法:

str.split(str="", num=string.count(str))

str --> 分隔符,默认为所有的空字符 包括空格 换行(\n) 制表符(\t)等。
num --> 分割次数。

例子:

str = "Line1-abcdef \nLine2-abc \nLine4-abcd";
print str.split( )
print str.split(' ', 1 )
['Line1-abcdef', 'Line2-abc', 'Line4-abcd']
['Line1-abcdef', '\nLine2-abc \nLine4-abcd']
s = "there is a string here"
s.splt()    # ['there','is','a','string','here']
s.split(" ",1)  #['there','is a string here']
s.spilt(" ",2) # ['there','is','a string here']

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions