我的任务是提供一个能够解密Cesar密码的程序,并且我正在查看以前在本站上提出的其他问题,并且大部分都了解它。但是,我只是有一个关于如何获得字符串中每个字母的基本问题。如何获取字符串中每个字母的计数?
这里就是我想出迄今:
Input=input("input the text you want to decipher:")
import string
print(string.ascii_uppercase)
def get_char(ch,shift):
#get a tally of the each letter
common_letter=#letter with most "tallies"
return common_letter
print(common_letter)
#finding the shift
def get_shift(s,ignore):
for x in Input:
shift=get_char-x
if shift=='e':
return x
print(x)
def output_plaintext(s,shift):
#convert back to English based off shift
pass
def main():
# main body where i call together my other functions
pass
input("is this decrypted?")
#if no is inputted re run program with second most common letter
如何获得每个字母的计数的字符串?
-Nathan
看来你错过了一些缩进这里,格式化,因为它是不应该运行在所有(尤其是最后两个功能)。 – fpietka
缩进在python中是正确的,在复制和粘贴时肯定已经搞乱了。 – Nathannn