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))”.
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
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
##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!