热门

最新

红包

立Flag

投票

同城

我的

发布
m0_73621864
小小雨鱼
2 年前
truem0_73621864

大众点评的数据爬取 每天都在修修改改缝缝补补 还是这样 都不知道怎么解决了。

CSDN App 扫码分享
分享
2
点赞
打赏
  • 复制链接
  • 举报
下一条:
from collections import Counterwith open('sample.txt', 'r') as f: text = f.read().lower()counter = Counter(c for c in text if c.isalpha())total_chars = sum(counter.values())with open('result.txt', 'w') as f: f.write(f'共{total_chars}个字符,其中每个字母的分布情况为:\n') for char, count in sorted(counter.items()): f.write(f'{char}:{count}, ')
立即登录