赞
踩
原本我认为这道题会很难
其实之后做完才发现并没有那么难…
没什么思路 会点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 character l = list(str(input()));secret = 0 for i in l: secret = (secret + ord(i))%26 f = open("mayun.txt","r") content = f.readlines() upperchr = lowerchr = num = space = others = words = 0 for line in content: for i in line: if i.isupper():upperchr+=1 elif i.islower():lowerchr+=1 elif i.isspace():space+=1 elif i.isdigit():num+=1 else:others+=1 str = 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 += char print(ret)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。