What does split mean in python?

silencement
Release: 2020-09-17 10:13:31
Original
137973 people have browsed it

Split in Python is a built-in function used to split strings. The split strings are returned in list form. The syntax of this function is "str.split(str="", num=string .count(str))”.

What does split mean in python?

The English translation of split is split. split() in Python splits a string into multiple strings and returns them in the form of a list.

Syntax:str.split(str="", num=string.count(str)), parameters: str -- separator, The default is all empty characters, including spaces, newlines (\n), tabs (\t), etc.; num -- the number of divisions. The default is -1, which separates everything. In other words, split() will be split by spaces when it takes no parameters, and when it is a parameter, it will be split by this parameter.

For example:

Without parameters

What does split mean in python?

Conclusion: When there are no parameters, the default is to use spaces as parameters, no matter where the spaces are, or if there are several, all of them are removed!

With parameters

What does split mean in python?

##The result is: ['', '', 'song', '', '', 'huan', '', '', '', 'gong', '']

The above is the detailed content of What does split mean in python?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!