0
点赞
收藏
分享

微信扫一扫

python统计和查找学校name字段的次数【多测师_王sir】

{
"suggestion": {
"keywords": [],
"cities": []
},
"count": "480",
"infocode": "10000",
"pois": [
{
"parent": [],
"distance": [],
"pcode": "110000",
"importance": [],
"biz_ext": {
"cost": [],
"rating": "3.5"
},
"recommend": "0",
"type": "科教文化服务;学校;职业技术学校",
"photos": [
{
"title": [],
"url": "http://store.is.autonavi.com/showpic/1ef496b95f968b539765108ceeed9da1"
}
],
"discount_num": "0",
"gridcode": "5916736920",
"typecode": "141206",
"shopinfo": "0",
"poiweight": [],
"citycode": "010",
"adname": "朝阳区",
"children": [
{
"typecode": " 991401 ",
"address": " 芳园里14号 ",
"distance": " 0 ",
"subtype": "门",
"sname": " 东北门 ",
"name": " 北京市电气工程学校(东北门) ",
"location": "116.488430,39.973181",
"id": " B000A84K1X "
}
],
"alias": [],
"tel": "010-64370704;010-64312167",
"id": "B000A7CSHN",
"tag": [],
"event": [],
"entr_location": "116.488432,39.973184",
"indoor_map": "0",
"email": [],
"timestamp": "2020-10-30 13:48:50",
"website": [],
"address": "将台路4号",
"adcode": "110105",
"pname": "北京市",
"biz_type": [],
"cityname": "北京市",
"postcode": [],
"match": "0",
"business_area": "酒仙桥",
"indoor_data": {
"cmsid": [],
"truefloor": [],
"cpid": [],
"floor": []
},
"childtype": [],
"exit_location": [],
"name": "北京市电气工程学校",
"location": "116.487715,39.972586",
"shopid": [],
"navi_poiid": "J50F001020_29805",
"groupbuy_num": "0"
},
{
"parent": [],
"distance": [],
"pcode": "110000",
"importance": [],
"biz_ext": {
"cost": [],
"rating": "3.5"
},
"recommend": "0",
"type": "科教文化服务;学校;职业技术学校",
"photos": [
{
"title": [],
"url": "http://store.is.autonavi.com/showpic/53a0ef41a310b133764ed908"
},
{
"title": [],

#coding=utf-8
"""
===========================
Author:多测师_王sir
Time:2020-11-04 10:46
===========================
"""

import re
def find_school():
'''
查找学校的次数
:return:
'''
with open('C:\project\dcs8\lesson\school.txt','r',encoding='utf-8')as f:
content = f.read() #读取文件所有的内容
value = re.findall('"name": "(.+?)"',content)
num = 0
for i in value:
num+=1
return '找到的学校字段的次数为{}次'.format(num)

if __name__ == '__main__':
count = find_school()
print(count)

运行结果为:找到的学校字段的次数为2次

 



举报

相关推荐

0 条评论