温馨提示×

python的拼接函数是什么

九三
295
2021-02-18 15:58:35
栏目: 编程语言
Python开发者专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

python的拼接函数是什么

python中的拼接函数是join()函数,使用方法如下:

1.拼接列表

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)

输出结果为:

Users/tuliyou/code

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:Python中path函数拼接路径的方法是什么

0