概述
列表里面元素的统计
from collections import Counter
text1 = "There are moments in life when you miss someone so much that you just want to pick them from your dreams and hug them for real! Dream what you want to dream"
text2 = text1.split(' ')
print(Counter(text2).most_common(1))
首字母大写(正则)
只是提供一种思路
import re
text1 = "There are moments in life when you miss someone so much that you just want to pick them from your dreams and hug them for real! Dream what you want to dream"
text2 = text1.split(' ')
print([w for w in text2 if re.search(r'^[A-Z]', w)])
最后
以上就是默默钢笔为你收集整理的python3内置函数一Counter列表里面元素的统计的全部内容,希望文章能够帮你解决python3内置函数一Counter列表里面元素的统计所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复