Python join()方法

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

Grammar:

str.join(sequence)

参数

  • sequence -- 要连接的元素序列。

返回值

返回通过指定字符连接序列中元素后生成的新字符串。

Case:

1 str1 ="--";
2 str2 =('a','b','c');
3 print str1.join(str2)  #等于join(str1,str2) 或是join str1 to str2

Output

a--b--c

quote:http://www.runoob.com/python/att-string-join.html

原文地址:https://www.cnblogs.com/sub2020/p/7865265.html