本文简述的是string.join(words[, sep]),它的功能是把字符串或者列表,元组等的元素给连接起来,返回一个字符串,和split()函数与正好相反,看下面的代码理解。
a=["豫","N","C8","C89"]
b=("豫","N","C8","C89")
c="zhang"
a1="-".join(a)
b1="-".join(b)
c1="-".join(c)
d="".join(a)
print(a1)
print(b1)
print(c1)
print(d)
输出:
豫-N-C8-C89
豫-N-C8-C89
z-h-a-n-g
豫NC8C89