#!/usr/bin/python #-*-encoding:utf-8-*- """ @file:tfidf.py @Contact:yinchao@qq.com @Lience:(c)Copyright2017-2018 @Modifty Time 2022/1/523:27 @Author yinchao @Version 1.0 @Desciption None """ def frequency(data,word): str = data.get("body") nums = counts(str) num = str.count(word) print("字符串字符个数:{},字符:{}在字符串:{}中,出现的次数是{}".format(nums,word,str,num)) #return num #求字符串中字符个数 def counts(str): nums = 0 for i in str: nums += 1 return nums #print(counts) # num_number=char_number=space_number=other_number=0 # for i in str: # if i.isdigit():#判断数字 # num_number+=1 # elif i.isspace():#判断空格 # space_number+=1 # elif i.isalpha():#判断英文单词 # char_number+=1 # else: # other_number+=1 # print("英文字符有:{} 数字字符有:{} 空格有:{} 特殊字符有:{}".format(char_number,num_number,space_number,other_number)) if __name__ == '__main__': # s = "123dsse ,../n" # count(s) dict_data = { "id": "c2403ca8e7137ab026ce2f849a4efc85", "pageTitle": "Frequently asked questions", "subTitles": [ "My Zoom account", "Where can I find my account owner?" ], "body": "You can find your account owner on your [Account Profile](https://zoom.us/account#) " "page of the Zoom web portal. [Learn more about the Account Profile page.]" "(https://support.zoom.us/hc/en-us/articles/115005731743-Account-Profile)\n\n" } word = "c" frequency(data=dict_data, word=word)