且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Python中的空格处拆分列表中的每个字符串

更新时间:2022-03-02 23:49:19

很难知道您要什么,但我会给您一个机会.

It's hard to know what you're asking for but I'll give it a shot.

>>> a = ['this is', 'a', 'list with  spaces']
>>> [words for segments in a for words in segments.split()]
['this', 'is', 'a', 'list', 'with', 'spaces']