Function: String.Join ()
Python has join () and Os.path.join () two functions, which work as follows:
Join (): An array of connection strings. Generates a new string from a string, tuple, or element in the list, with the specified character (delimiter) connection
Os.path.join (): Combine multiple paths to return
First, function description
1. Join () function
Syntax: ' Sep '. Join (SEQ)
Parameter description
Sep: Delimiter. Can be empty
SEQ: sequence of elements to concatenate, strings, tuples, dictionaries
The syntax above is to combine all the SEQ elements into a new string with Sep as a delimiter
Return value: Returns a string that is generated after each element is concatenated with the delimiter Sep
2. Os.path.join () function
Syntax: Os.path.join (path1[,path2[,......])
Return value: Combine multiple paths to return
Note: Parameters before the first absolute path are ignored
1#对序列进行操作 (respectively, use' 'And':'as a delimiter)2 3>>> seq1 = ['Hello','Good',' Boy','Doiido']4>>> Print' '. Join (SEQ1)5 Hello good boy doiido6>>> Print':'. Join (SEQ1)7 Hello:good:boy:doiido8 9 Ten #对字符串进行操作 One A>>> SEQ2 ="Hello good boy doiido" ->>> Print':'. Join (SEQ2) - h:e:l:l:o:: g:o:o:d:: b:o:y::d: O:i:i:d:o the - - #对元组进行操作 - +>>> seq3 = ('Hello','Good',' Boy','Doiido') ->>> Print':'. Join (SEQ3) + Hello:good:boy:doiido A at - #对字典进行操作 - ->>> Seq4 = {'Hello':1,'Good':2,' Boy':3,'Doiido':4} ->>> Print':'. Join (SEQ4) - Boy:good:doiido:hello in - to #合并目录 + ->>>Import OS the>>> Os.path.join ('/hello/','good/boy/','Doiido') * '/hello/good/boy/doiido'
Excerpt from blog: https://www.cnblogs.com/jsplyy/p/5634640.html
The use of the Join () function in Python