当前位置:网站首页>自己寻找一个记事本文件,数据素材自找,统计整个文本中,某三个关键字或者语句词条出现的次数。
自己寻找一个记事本文件,数据素材自找,统计整个文本中,某三个关键字或者语句词条出现的次数。
2022-04-22 06:12:00 【欣慰的三叶草(● ̄(エ) ̄●)】
自己寻找一个记事本文件,数据素材自找,统计整个文本中,某三个关键字或者语句词条出现的次数。
conten = '''河南经贸职业学院(Henan Institute of Economics and Trade), 坐落于河南省郑州市,2004年由河南省人民政府批准成立、教育部备案、 隶属于河南省教育厅管理的一所全日制普通高等院校,河南省首批示范性高职院校。'''
import re
with open('C.txt', 'a') as f:
f.write(conten)
with open('C.txt', 'r') as f:
count = 0
for c in f.readlines():
str1 = re.findall('河南省', c)
if len(str1) > 0:
count += str1.count('河南省')
print('在C.txt文件中查找出"河南省"出现 {}次'.format(count))

版权声明
本文为[欣慰的三叶草(● ̄(エ) ̄●)]所创,转载请带上原文链接,感谢
https://blog.csdn.net/cygqtt/article/details/106489032
边栏推荐
猜你喜欢

Nacos集群配置

微信第三方网页授权

Service configuration center of Nacos

Distributed task scheduling and computing framework: powerjob advanced features - container 03

腾讯云对象存储服务的使用

mysql的zip安装教程

STM32 timer ocref output configuration timx - > CCER

如何成为IC验证工程师?

Format control of format() method

Relationship between Nacos namespace grouping and dataid
随机推荐
分布式任务调度与计算框架:PowerJob 高级特性-容器 03
Application of can card in robot system
C#日常开发随手记------获取华为云桶中ZIP内的所有文件(包含System.NotSupportedException:“此流不支持查找操作“解决方法)
【JEECG】修改Viser图表颜色样式
RSS入坑指南
旋转选择器 WheelPicker 的使用
微信小程序 canvas 画简单的仪表盘 渐近色
Nacos持久化切换配置
.NET学习笔记----关于.NET Core那些事(1)【.netcore的项目结构、五种向页面传值的方式、Log4Net和NLog的使用】
微信第三方网页授权
Nacos之服务配置中心
.NET日常想法随手记------比较两个json文件并获取标签相同但值却不同的数据
用大写的字段接受最终首字母却变小写
What knowledge and skills need to be added to IC design?
Scope and lifetime (Mr. Weng Kai)
Notes on C # daily development ----- obtain all files in the zip in Huawei cloud bucket (including system. Notsupportedexception: "this stream does not support search operation" solution)
Leetcode punch in
leetcode 打卡
Introduction to IC Analog Layout - learning notes on layout Basics (2)
作用域与生存期(翁恺老师)