Latest web development tutorials

Python3 join () method

Python3 string Python3 string


description

Python join () method is used to specify the elements of a sequence of characters to generate a new connection string.

grammar

join () method syntax:

str.join(sequence)

parameter

  • sequence - a sequence of elements to be connected.

return value

Returns a new string after connecting elements in a sequence generated by the specified character.

Examples

The following example shows the join () method of use:

#!/usr/bin/python3

s1 = "-"
s2 = ""
seq = ("r", "u", "n", "o", "o", "b") # 字符串序列
print (s1.join( seq ))
print (s2.join( seq ))

Examples of the above output results are as follows:

r-u-n-o-o-b
w3big

Python3 string Python3 string