方法一
from collections import Counter
import re
with open(\'../one_one.py\',encoding="utf-8",)as f:
f1 = f.read()
rest = re.findall(r\'[a-zA-Z].+\',f1)
res = Counter(rest)
print(res)
for k,l in res.items():
print("%s:%s" % (k,l))
方法二
import re
with open(\'../one_one.py\',encoding="utf-8", )as f:
f1 = f.read()
f2 = re.sub(r"[.?!,()/#:\'=->]", \' \', f1)
res = f1.split()
print(res)
dict1 = {}
for k in res:
if re.findall(r\'[a-zA-Z]\',k):
ress = res.count(k)
dict1[k] = ress
print(dict1)
ll = sorted(dict1.items(),key=lambda x:x[1],reverse=True)
print(ll)
相关文章:
- 英语单词统计 2022-12-23
- 统计英语文章中单词 2021-11-02
- 统计英语文章的单词 2021-11-02
- Hadoop-Mapreduce-英文单词计数 2021-05-25
- 统计一个文件英文单词的个数 2022-12-23
- 统计一篇英文文章中的单词数 2022-12-23
- Javafx-【直方图】文本频次统计工具 中文/英文单词统计 2022-12-23
- python统计英文文本中的回文单词数 2020-05-13