我需要从获得的数值到字符以拼出它不起作用的单词的部分,它说我需要在最后一部分使用整数?
接受字符串
print "This program reduces and decodes a coded message and determines if it is a palindrome"
string=(str(raw_input("The code is:")))
将其更改为小写
string_lowercase=string.lower()
print "lower case string is:", string_lowercase
去除特殊字符
specialcharacters="1234567890~`!@#$%^&*()_-+={[}]|\:;'<,>.?/"
for char in specialcharacters:
string_lowercase=string_lowercase.replace(char,"")
print "With the specials stripped out the string is:", string_lowercase
输入偏移
offset=(int(raw_input("enter offset:")))
将文本转换为 ASCII 码
result=[]
for i in string_lowercase:
code=ord(i)
result.append([code-offset])
从 ASCII 码到文本的转换
text=''.join(chr(i) for i in result)
print "The decoded string is:", text.format(chr(result))