python中的jion

it2026-04-25  7

python中的jion

on将列表或元组中的每个元素连接起来,举个例子:

1 a = ["hello", "world", "dlrb"] 2 a1 = "_".join(a) 3 print(a1)

输出结果:

hello_world_dlrb

"_".join(a) 的作用:使用 _ 下划线将列表a中的每一个元素连接起来,当然你可以选择自己想要用的连接方法

 

1 b = ("hello", "world", "dlrb") 2 b1 = "*".join(a) 3 print(b1)

输出结果:

hello*world*dlrb

和列表同理

posted on 2019-04-09 10:12 恒笛 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/xwqhl/p/10675220.html

最新回复(0)