百科问答小站 logo
百科问答小站 font logo



Python中有什么方法能将一段英文里的不重复单词挑出来? 第1页

  

user avatar   PandoraEartha 网友的相关建议: 
      

       string='the tree turn green and green' words=string.split() wordsCount={} for word in words:     wordsCount[word]=wordsCount.get(word,0)+1 for wordsCounted in wordsCount.keys():     if wordsCount[wordsCounted]==1:         print(wordsCounted)     


user avatar    网友的相关建议: 
      
       def _pick_words(s: str):     from collections import Counter     words = s.split()     result = Counter(words)     return [w for w, t in result.items() if t == 1]     


       def _pick_words(s: str):     result = {}     words = s.split()     for word in words:         times = result.get(word, 0)         result[word] = times + 1     return [w for w, t in result.items() if t == 1]     




  

相关话题

  三维数据统计分析和可视化都有哪些优秀的开源项目? 
  作为非计算机专业的学生,觉得 C 语言远比其他语言易于上手,正常吗? 
  知乎上这么多推崇学 Python 入 IT 行的,如果他们学完 Python 这一套找不到工作怎么办? 
  如何设计制度,才能使程序员职位被程序员世家垄断? 
  Python在数据科学领域能否完全取代R? 
  为什么苹果新语言 Swift 的 RC4 运算效能是 Python 的 220 倍? 
  Python 在大部分领域都能胜任,为什么很多企业转向了 Golang? 
  python适合什么年龄自学? 
  学习python为什么要在linux下?怎么学? 
  python到底学什么? 

前一个讨论
为什么《原神》会有大佬帮忙做任务?
下一个讨论
家人们,帮我看看这个极限?





© 2025-05-13 - tinynew.org. All Rights Reserved.
© 2025-05-13 - tinynew.org. 保留所有权利