百科问答小站 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]     




  

相关话题

  为什么有人说 Python 的多线程是鸡肋呢? 
  目前比较好用的python开发工具是哪一个? 
  银行业为什么喜欢用 sas 而不是 python? 
  C#程序如何调用Python程序? 
  C#程序如何调用Python程序? 
  python大型开源项目如何组织代码? 
  你是如何自学 Python 的? 
  R 和 Python (numpy scipy pandas) 用于统计学分析,哪个更好? 
  如何看待“Python星人”这个群体? 
  一个程序员多年累计编写一百万行代码是什么体验? 

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





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