Python join()方法

Python join() 方法用于将序列中的元素以指定的字符连接生成一个新的字符串。

join()方法语法:

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

输出:

r-u-n-o-o-b
runoob