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

Arc*_*rc' -2 python url split list

我有一个列表,其中包含Python中大型列表的每个项目中的URL和一些文本.我想在每次出现空格时将每个项目分成几个项目(每个项目2-3个空格).发布的代码不多,它只是一个存储在命名变量中的列表.我已经尝试过使用split功能,但我似乎无法正确使用它.任何帮助将不胜感激!

Mar*_*som 6

很难知道你要求的是什么,但我会试一试.

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