网页学习体会

  • 首页
  • 个人博客
您的位置: 首页  >  技术问答  >  文本字符分布。。。。。。。

文本字符分布。。。。。。。

分类: 技术问答 • 2022-03-13 21:32:24

文本字符分布。。。。。。。

问题描述:

 

答

with open('data.txt', 'r') as f:
    s = f.readlines()
dict1 = {}
for sj in s:
    sj = str(sj.strip())
    for i in sj:
        if dict1.get(i,0):
            dict1[i] += 1
        else:
            dict1[i] = 1
dict1 = sorted(dict1.items(), key=lambda x:x[0])
for key,value in dict1:
    print("{}:{}".format(key,value))

相关推荐

  • springboot分布式数据源(Mysql)
  • 49.字符串转int
  • 随机生成N位字符串 String,StringBuffer与StringBuilder的区别|线程安全与线程不安全
  • leetcode无重复字符最长子串
  • windows下《七天学会NodeJS》学习笔记之三--文件操作 小文件拷贝 大文件拷贝 Buffer(数据块)http://nodejs.org/api/buffer.html Stream(数据流)[http://nodejs.org/api/stream.html) File System(文件系统)[http://nodejs.org/api/fs.html) Path(路径)[http://nodejs.org/api/path.html) 遍历目录 文本编码
  • Python中关于字符串的问题
  • Redis分布式锁
  • SQL中判断一串字符中是否有特定的字符
  • 普通文本(.txt)篇章排版样式参考 [文档说明][日志]
  • Machine Learning 23 -- 文本分类实例
  • 关于beautifulsoup中的tag的类型问题
  • 班长发子弹问题python怎么写
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 网页学习体会    备案号:   粤ICP备20002247号