百科问答小站 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 有哪些能够应用在物理(尤其是凝聚态当中)的 package?主要功能是什么? 
  Python 语言有什么奇技淫巧吗? 
  python学习一定用pycharm吗? 
  零基础学python拼命学最快要多久? 
  使用 Visual Studio 开发的情况下 C# 的编程效率能否和 Python、Ruby 媲美? 
  Python 中有什么不容易让人察觉的有趣的事实? 
  Python中一个字符串的所有字母用它的后继字母代替(比如,a用b代替,b用c代替),怎么搞? 
  VBA会被Python代替吗? 
  已有大量编程基础,如何速成python用于学习机器学习? 
  python到底学什么? 

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





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