我目前正在尝试制作一个凯撒解码器,所以我正试图找出如何让用户输入值的变化,并使用该输入来移动列表中的每个项目。但每次尝试时,都会给我一个错误。如何增加列表中每个项目/元素的值?
例如:
word
在ASCII是:
[119, 111, 114, 100]
如果移给定的输入是2
,我希望该列表是:
[121, 113, 116, 102]
请帮帮我。这是我第一次编程,这凯撒解码器是让我疯:(
这是我迄今为止
import string
def main():
inString = raw_input("Please enter the word to be "
"translated: ")
key = raw_input("What is the key value or the shift? ")
toConv = [ord(i) for i in inString] # now want to shift it by key value
#toConv = [x+key for x in toConv] # this is not working, error gives 'cannot add int and str
print "This is toConv", toConv
而且,这将是有益的,如果你们不使用任何花哨的功能而是,请使用现有的代码,我是新手
+1的解释 –