所以,我想做的是,如果你有以下清单:
example_list=['This', 'is', 'QQQQQ', 'an', 'QQQQQ', 'example', 'list', 'QQQQQ', '.']
我希望它重组如下:
example_list=['This is', 'an', 'example list', '.']
注意qq是如何被用作占位符的。所以,基本上我希望qqs之间的所有东西都是一个列表元素。我该怎么做?你知道吗
我也看过其他关于join()函数的文章,但我遇到的问题是,如果有多个单词,就在它们之间加一个空格。你知道吗
尝试
join
和strip()
一起去除空白输出
您可以使用^{} :
或者甚至用^{} 比较,正如@tobias_k在评论中所建议的:
使用简单的迭代。你知道吗
例如:
输出:
相关问题 更多 >
编程相关推荐