阅读背景:

我得到了一个类型错误:字符串索引必须是整数,而不是类型。

来源:互联网 
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
key = "XPMGTDHLYONZBWEARKJUFSCIQV" 

def encode():
    alpha[""] = key["x"]

def decode():
    key[""] = alpha[""] 

def menu():
    response = raw_input("""Crypto Menu
        quit(0)
        encode(1)
        decode(2)""")
    return response

def main():   
    keepGoing = True
    while keepGoing:
    response = menu()
    if response == "1":
        plain = raw_input("text to be encoded: ")
        print encode()
    elif response == "2":
        coded = raw_input("code to be decyphered: ")
        print decode()
    elif response == "0":
        print "Thanks for doing secret spy stuff with me."
        keepGoing = False
    else:
        print "I don't know what you want to do..."

print main()
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
key = "XPM



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: