怎么用python里的join连接字符串里的元素

example_list = [[‘this’, ‘is’], [‘a’, ‘test’]]

变成 This is a test

我只知道怎么连接 [‘this’, ‘is’, ‘a’, ‘test’] 这样子的 但是中间还有中括号

s = " ".join([" ".join(x) for x in example_list])
你题目的解答代码如下:

example_list = [['this', 'is'], ['a', 'test']]

s = " ".join([" ".join(x) for x in example_list])

print(s)

img

如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!

img

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632