【发布时间】:2019-06-01 09:42:13
【问题描述】:
我在 python 中有以下列表
texts = [
["great", "even", "for", "the", "non", "runner", "this", "sound",
"track", "was", "brilliant"],
["cannot", "recommend", "as", "a", "former", "comrade", "i", "did",
"not", "want", "to", "have", "to", "do", "this"]
]
我想浏览列表并计算每个单词出现在其中的频率。
我尝试使用 length() 计算单个单词,结果得到 2,这意味着它不起作用。
有什么方法可以计算一个单词在列表中出现的频率,因为我打算将计数的单词存储在一个新列表中,并将它的频率存储在另一个列表中。
提前致谢
【问题讨论】:
标签: python python-3.x