【发布时间】:2012-07-27 21:48:18
【问题描述】:
我有一个如下所示的元组列表:
[('this', 'is'), ('is', 'the'), ('the', 'first'), ('first', 'document'), ('document', '.')]
将每个标记用空格分隔的最pythonic和最有效的方法是什么:
['this is', 'is the', 'the first', 'first document', 'document .']
【问题讨论】:
-
我添加了一个避免使用
%s的答案,对于3.6+版本,它使用f-string,对于以前的版本,它使用str.format。
标签: python