Python-Join () Pythonjoinos
The moon seems to be at that time.
Total
In Python, there are two join methods, one is Str.join () and the other is Os.path.join (), which only understands the previous
Str.join (iterable)
Official documents
Return a string which is the concatenation of the strings in iterable. A TypeError'll be raised if there is any non-string the values in Iterable, including bytes objects. The separator between elements is the string providing this method.
To put it simply, the elements in an iterative object are stitched back together in Str, but these elements must be of type String, or the error will be
< Code data-info= "" class= "Nohighlight hljs" style= "border:0; font-size:90%; Background-color: #FFCCCC; Color: #f8f8f2; Padding-top:0.5em; Padding-right:0.5em; Padding-bottom:0.5em; Padding-left:0.5em; Overflow:visible!important; Display:block; Background: #282a36 "># error >>> L = [1,2,3]>>>" ". Join (L) Traceback (most recent call last): File" <std In> ", line 1, in <module>typeerror:sequence item 0:expected str instance, int found# to list stitching >>> L = ["Hello", "pinsily"]>>> "". Join (L) ' Hello pinsily ' # to string concatenation >>> s = "Hello pinsily" >>> ":". J Oin (s) ' H:e:l:l:o::p: I:n:s:i:l:y ' # for tuple stitching >>> t = ("Hello", "pinsily") >>> "". Join (t) ' Hello pinsily ' # To the dictionary stitching >>> d = {"Hello": "1", "pinsily": "2", "and": "3", "World": "4"}>>> "". Join (d) ' Hello pinsily and World '
Note : When you want to use a lot of string stitching, try to avoid + the operation, which will produce a lot of temporary variables, occupy memory, you can first stitching it into the list, and then use the join method
Python-Join ()