Python | 词频统计

2017-12-27  本文已影响99人  Sudden

最近工作蛮忙的,就简单练习一下python基础吧。

本周的练习是词频统计,主要使用了以下几个函数:

  1. text.split( ) #将text以空格为分隔符,分为若干个部分
  2. lista.append(word) #在lista末尾增加word所指的单词
  3. indexa=unique_words.index(word) #找到unique_words中元素值为word的元素所对应的索引值,赋值给indexa
  4. unique_words[indexa] #对uniqe_words进行切片,取出索引值为indexa的位置的元素
  5. for循环

练习源代码我放在了github上,欢迎交流~~
https://github.com/Suddennebbus/Python_Learning/blob/master/Lesson2%2B%E8%AF%8D%E9%A2%91%E7%BB%9F%E8%AE%A1.ipynb

上一篇下一篇

猜你喜欢

热点阅读