python中的拼接函数是join()函数,使用方法如下:
1.拼接列表
list_val = ["www","baidu","com"]str_val = ".".join(list_val)print(str_val)
list_val = ["www","baidu","com"]
str_val = ".".join(list_val)
print(str_val)
输出结果为:
www.baidu.com
2.拼接元组
tuple = ('Users','tuliyou','code')str_val = '/'.join(tuple)print(str_val)
tuple = ('Users','tuliyou','code')
str_val = '/'.join(tuple)
Users/tuliyou/code