文章目录
- 前引
- 原题题目
- 代码实现
- 提交结果
前引
原本我认为这道题会很难 其实之后做完才发现并没有那么难… 没什么思路 会点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)