百科问答小站 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也是才开始学,现在导师要我做LSTM,我应该去学什么? 
  python中的模块、库、包有什么区别? 
  高频交易中C++和Python的速度差异有多少? 
  你们都是怎么学 Python 的? 
  怎样才能写出 Pythonic 的代码? 
  python适合什么年龄自学? 
  如何零基础入门 Python? 
  你们都用Python实现了哪些办公自动化? 
  按键精灵等以GUI接口为基础的程序在爬虫界的地位是怎样的? 
  Python中for i in somelist,如果在for循环内改变somelist会发生什么? 

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





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