指示:
编辑:我只需要方法菜单返回“即将推出”,因为 - 就目前而言,如果用户输入 c、p 或 s,它什么也不返回。我看不出有什么合乎逻辑的原因。
def PrintDescription():
print 'This program encrypts and descrypts messages using multiple \
encryption methods.\nInput files must be in the same directory as this program.\
\nOutput files will be created in this same directory.'
def StartMenu():
print 'Do you wish to encrypt or decrypt?'
print '<e>ncrypt'
print '<d>ecrypt'
print '<q>uit'
def MethodMenu():
print 'Which method would you like to use?'
print '<c>aesarian fixed offset'
print '<p>seudo-random offset'
print '<s>ubstitution cipher'
a = raw_input("")
while a not in ('c', 'p', 's'):
if a:
print "Error: You must type c, p, or s"
a = raw_input("")
if a == 'c' or a=='p' or a=='s':
print 'Coming Soon'
def main():
alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.?! \t\n\r"
PrintDescription()
a = None
while a not in ('e', 'd', 'q'):
if a:
print "Error: You must type e, d, or q"
else:
StartMenu()
a = raw_input("")
if a == 'e' or a=='d':
MethodMenu()
if a == 'q':
break
main()