Python文本分析与加密作业中,如何识别并处理长尾词?
- 内容介绍
- 文章标签
- 相关推荐
本文共计481个文字,预计阅读时间需要2分钟。
原文:文章目录前引主题:主题代码实现,提交结果前引原理。我认为这道题会很困难,其实之后做完才发现并没有那么难……没有什么思路,会用Python的应该都看得懂我的代码,代码非常直白,不拐弯抹角,就这样的了。
改写后:目录引言:探讨主题代码实现,结果展示前,先阐述原理。起初以为题目难度大,完成后却发现相对容易。思路不复杂,Python使用者应能轻松理解我的代码。代码简洁明了,无冗余,直接呈现。
文章目录前引原题题目代码实现提交结果前引原本我认为这道题会很难其实之后做完才发现并没有那么难…没什么思路会点python的应该都看得懂我的代码代码很直白不拐弯抹角就这样了原题题目代文章目录
- 前引
- 原题题目
- 代码实现
- 提交结果
前引
原本我认为这道题会很难 其实之后做完才发现并没有那么难… 没什么思路 会点python的应该都看得懂我的代码 代码很直白 不拐弯抹角 就这样了
原题题目
代码实现
def encrypating(character,n):if character.islower():temp = ord(a);character = chr(temp+(ord(character)-temp+n)%26)else:temp = ord(A);character = chr(temp+(ord(character)-temp+n)%26)return characterl = list(str(input()));secret = 0for i in l:secret = (secret + ord(i))%26f = open("mayun.txt","r")content = f.readlines()upperchr = lowerchr = num = space = others = words = 0for line in content:for i in line:if i.isupper():upperchr+=1elif i.islower():lowerchr+=1elif i.isspace():space+=1elif i.isdigit():num+=1else:others+=1str = line.replace(., )str = str.replace(,, )str = str.replace("", )l = list(str.split( ))words+=len(l)print("%d %d %d %d %d"%(upperchr,lowerchr,num,space,others))print("%d words in all"% words)print("%d"% secret)for line in content:ret = ""for char in line:if char.isalpha():ret += encrypating(char,secret)elif char != \n:ret += charprint(ret)
提交结果
本文共计481个文字,预计阅读时间需要2分钟。
原文:文章目录前引主题:主题代码实现,提交结果前引原理。我认为这道题会很困难,其实之后做完才发现并没有那么难……没有什么思路,会用Python的应该都看得懂我的代码,代码非常直白,不拐弯抹角,就这样的了。
改写后:目录引言:探讨主题代码实现,结果展示前,先阐述原理。起初以为题目难度大,完成后却发现相对容易。思路不复杂,Python使用者应能轻松理解我的代码。代码简洁明了,无冗余,直接呈现。
文章目录前引原题题目代码实现提交结果前引原本我认为这道题会很难其实之后做完才发现并没有那么难…没什么思路会点python的应该都看得懂我的代码代码很直白不拐弯抹角就这样了原题题目代文章目录
- 前引
- 原题题目
- 代码实现
- 提交结果
前引
原本我认为这道题会很难 其实之后做完才发现并没有那么难… 没什么思路 会点python的应该都看得懂我的代码 代码很直白 不拐弯抹角 就这样了
原题题目
代码实现
def encrypating(character,n):if character.islower():temp = ord(a);character = chr(temp+(ord(character)-temp+n)%26)else:temp = ord(A);character = chr(temp+(ord(character)-temp+n)%26)return characterl = list(str(input()));secret = 0for i in l:secret = (secret + ord(i))%26f = open("mayun.txt","r")content = f.readlines()upperchr = lowerchr = num = space = others = words = 0for line in content:for i in line:if i.isupper():upperchr+=1elif i.islower():lowerchr+=1elif i.isspace():space+=1elif i.isdigit():num+=1else:others+=1str = line.replace(., )str = str.replace(,, )str = str.replace("", )l = list(str.split( ))words+=len(l)print("%d %d %d %d %d"%(upperchr,lowerchr,num,space,others))print("%d words in all"% words)print("%d"% secret)for line in content:ret = ""for char in line:if char.isalpha():ret += encrypating(char,secret)elif char != \n:ret += charprint(ret)

