将列表中的字符串仅放入列表中的字符串

时间:2018-03-16 06:39:09

标签: python

如何将列表中的所有字符串合并为一个大字符串? 例如:

alist = ["Hi","How are YOU","THANK YOU"]

我如何进入:

alist = ["Hi,How are YOU, THANK YOU"]

2 个答案:

答案 0 :(得分:1)

您可以使用str.join方法。

<强>实施例

print([", ".join( ["Hi","How are YOU","THANK YOU"])])

<强> More Info

答案 1 :(得分:1)

使用join()

alist = [', '.join(alist)]

实施例

alist = ["Hi","How are YOU","THANK YOU"]
alist = [', '.join(alist)]
print(alist)

输出

['Hi, How are YOU, THANK YOU']