Example of join and split usage in Python, pythonjoin
Join is used to connect strings. split is the opposite.
I don't need to explain it much. After reading the code, I can see it myself.
Copy codeThe Code is as follows:
>>> Li = ['my, 'name', 'is, 'bob']
>>> ''. Join (li)
'My name is bob'
>>> S = '_'. join (li)
>>> S
'My _ name_is_bob'
>>> S. split ('_')
['My, 'name', 'is, 'bob']
The English versions of join and split are as follows:
Join (...)
S. join (sequence)-> string
Return a string which is the concatenation of the strings in
Sequence. The separator between elements is S.
Split (...)
S. split ([sep [, maxsplit])-> list of strings
Return a list of the words in the string S, using sep as
Delimiter string. If maxsplit is given, at most maxsplit
Splits are done. If sep is not specified or is None, any
Whitespace string is a separator and empty strings are removed
From the result.