Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#434 Python split() #9

Open
LiuL0703 opened this issue May 18, 2017 · 0 comments
Open

#434 Python split() #9

LiuL0703 opened this issue May 18, 2017 · 0 comments

Comments

@LiuL0703
Copy link
Owner

LiuL0703 commented May 18, 2017

语法:

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']
LiuL0703 added a commit that referenced this issue May 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant