One is the split, the other is the connection.
Convention, see the internal help document first
Help on Method_descriptor:join (...) S.join (iterable), String Return a string which is the concatenation of the strings in the Iterable . The separator between elements is S. (END)
The iterated object (which should contain the STR type or error) is concatenated, and the return value is str, as follows:
In [2]: s = [' Hello ', ' World ']in [3]: ' _ '. Join (s) out[3]: ' Hello_world ' in [4]: ". Join (s) out[4]: ' HelloWorld ' in [5]: ' && '. Join (s) out[5]: ' Hello&&world ' in [6]: ' _ '. Join ((1, 2, 3)) ---------------------------------- -----------------------------------------TypeError Traceback (most recent) < Ipython-input-6-48e56abfc814> in <module> ()----> 1 ' _ '. Join ((1, 2, 3) typeerror:sequence Item 0:expected St ring, int found
Look again at the Split function:
Help on Method_descriptor:split (...) S.split ([Sep [, Maxsplit]]), List of strings Return A list of the words in the string S, using Sep as the Deli Miter string. If Maxsplit is given, at most maxsplit splits be done. If Sep is no specified or is None, any whitespace string is a separator and empty strings be removed from the re Sult. (END)
The string is split, the space or null character is removed, the return value is a list of STR, the second parameter is the number of splits, and is used as follows:
In [9]: s = ' life was short, I use Python ' In [ten]: S.spls.split s.splitlines in [ten]: S.split () out[10]: [' Life ' , ' is ', ' short, ', ' I ', ' use ', ' Python ']in [all]: S.split (', ') out[11]: [' Life was short ', ' I use Python ']in []: S.split (', ' or '. ') OUT[12]: [' Life was short ', ' I use Python ']in []: S.split (', ', 3) OUT[13]: [' Life was short ', ' I us e Python ']in []: S.split (', ', 5) OUT[14]: [' Life was short ', ' I use Python ']in []: s = ' Hello, wo Rld. Life was short, I use Python ' in [+]: s.split (', ', 5) out[16]: [' Hello ', ' world. Life was short ', ' I use Python ']in [+]: s.split (', ', 2) out[17]: [' Hello ', ' world. Life was short ', ' I use Python ']in [+]: s.split (', ', 1) out[18]: [' Hello ', ' world. Life was short, I use Python ']in [+]: s.split (', ' or '. ', 2) out[19]: [' Hello ', ' world. Life was short ', ' I use Python ']
Join and split functions in Python