您可以使用简单的列表推导,例如:
newlist = [ **word** for line in mylist **for word in line.split()** ]
这将产生:
>>> [word for line in mylist for word in line.split()]['this', 'is', 'a', 'string', 'of', 'text', 'this', 'is', 'a', 'different', 'string', 'of', 'text', 'and', 'for', 'good', 'measure', 'here', 'is', 'another', 'one']
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)