太多的无奈之后,我做了我的第一个凯撒解码器:)如何在Python(2.7)中制作凯撒解码器循环?
但是现在的问题是,使程序循环...
例如,如果我们想转变doge
1,无问题,这是ephf
...
但xyz
,而转移是4?
所以编程专业人员帮助第一次新手又名福利局了:P 谢谢...
import string
def main():
inString = raw_input("Please enter the word to be "
"translated: ")
key = int(raw_input("What is the key value? "))
toConv = [ord(i) for i in inString] #now want to shift it by key
toConv = [x+key for x in toConv]
#^can use map(lambda x:x+key, toConv)
result = ''.join(chr(i) for i in toConv)
print "This is the final result due to the shift", result
相关:http://codereview.stackexchange.com/questions/32694/python-caesars-cipher-how-could-i-do-it-better/32696#32696 – kojiro