난으로 편지를 디코딩이 기능을 가지고 난 그렇게 단어 디코딩,이 작업을 얻기 위해 노력하고 키파이썬에서 Ascii 디코딩 기능, 무엇이 잘못 되었나요?
def decode_char(n, key):
adj = ord('a') if n.islower() else ord('A')
return chr(adj + (ord(n)-adj-int(key))%26)
주어진
def decode_block(word,key):
letters = list(word)
keys = list(key)
decoded = []
for letter, digit in zip(letters, keys):
decoded.append(decode_char(letter, digit))
return "".join(decoded)
때 입력이
print(decode_char('bddffhhj', '12121212'))
이 오류 메시지가 표시됩니다.
TypeError: ord() expected a character, but string of length 8 found
,210
나는 decode_char
에서 ord(n)
가 문자를 recieveing되지 않는 이유를 알아낼 수 없습니다
abcdefgh
을 얻을 필요가?
단어를 목록으로 나눕니까? 열쇠의 자릿수로 압축 했나요?
그냥 학생은 너무 햄
사람을 이동하지 마십시오?
의미? 코드의 예상 출력과 설명은 여기서 많은 도움이됩니다. 편집 : 그리고 "그것은 작동하지 않습니다"미래의 질문에 말하지 말아요) –
@ GerryHernandez 위로 편집 됨 –
Incase 당신이 찾고있는 : [Caesar Cipher] (http://stackoverflow.com/questions/8886947/caesar-cipher- function-in-python) – bhansa