私が取得した数値の値から文字に変換する必要がある部分は、それが機能しないという単語を綴るために、最後の部分に整数を使用する必要があると言いますか?数値をASCII文字に変換しますか?
は、文字列が
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~`[email protected]#$%^&*()_-+={[}]|\:;'<,>.?/"
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])
あなたがresult.append([code-offset])
を呼び出すときに代わりにintのリストのリストのリストを持っているように見えます
text=''.join(chr(i) for i in result)
print "The decoded string is:", text.format(chr(result))
あなたが「動作しない」とはどういう意味ですか?また、 "strip special characters"部分については、 'import string'を先に使ったと仮定して、string_lowercase = [x for string_lowercase in x in string.ascii_letters]'に行きました。最後に、変数に 'string'という名前を付けないでください。 – Efferalgan
** "パート[...]は機能していません" **。どちらの部分ですか、なぜ私たちに多くの他の部分も見せてくれるのですが、どこに問題があるのか混乱させますか?より良いことだけを見せて、間違ったことをする最初の部分について質問してください。 (後の部分は、間違ったデータを取得しているだけなので、何かが間違っている可能性があります。) –