如何通过在python中拆分列表元素来创建列表?

die*_*lar 3 python list

比方说我有:

sentences = ['The girls are gorgeous', 'I'm mexican']
Run Code Online (Sandbox Code Playgroud)

我想获得:

words = ['The','girls','are','gorgeous', 'I'm', 'mexican']
Run Code Online (Sandbox Code Playgroud)

我试过了:

words = [w.split(' ') for w in sentences] 
Run Code Online (Sandbox Code Playgroud)

但没有预期的结果.

这对于Counter(单词)是否有效,因为我需要获得频率?

Sye*_*b M 6

试试这样吧

sentences = ["The girls are gorgeous", "I'm mexican"]
words = [word for sentence in sentences for word in sentence.split(' ')]
Run Code Online (Sandbox Code Playgroud)