当前位置:   article > 正文

python菜鸟教程 | wordcount词频统计_3 wordcount_dict=dict(zip(df_filtered['word'],df_f

3 wordcount_dict=dict(zip(df_filtered['word'],df_filtered['count'])) 4 wordc
python实现wordcount词频统计
  1. class Solution(object):
  2. def singleNumber(self, nums):
  3. """
  4. :type nums: List[int]
  5. :rtype: int
  6. """
  7. dict={}
  8. for i in nums:
  9. if i in dict.keys():
  10. dict[i] = dict[i]+1
  11. else:
  12. dict[i] = 1
  13. for key, value in dict.items():
  14. print(str(key)+"出现了"+str(value)+"次")
  15. if __name__ == '__main__':
  16. array=[2,2,3,2]
  17. solution=Solution()
  18. print(solution.singleNumber(array))

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/388241
推荐阅读
相关标签
  

闽ICP备14008679号