0
나는 내가하고있는 과정에서 질문에 답하기 위해 쓰려고하는 스크립트에 심각한 문제가 있습니다. 계속 SyntaxError : 구문이 올바르지 않습니다. 138 조금 이상합니다. 여기에 내 대본이있다. 누군가가 이것을 풀 수있는 방법을 설명 할 수 있다면 멋질 것입니다. 이 두 라인 사이구문 오류 : 잘못된 구문 줄 138 예기치 않은 오류
class Message(object):
def __init__(self, text):
self.message_text = text
self.valid_words = load_words(WORDLIST_FILENAME)
def get_message_text(self):
return self.message_text
def get_valid_words(self):
return self.valid_words[:]
def build_shift_dict(self, shift):
lc_str = string.ascii_lowercase
uc_str = string.ascii_uppercase
shifted_dict = {}
for ltr in lc_str:
if lc_str.index(ltr) + shift < 26:
shifted_dict[ltr] = lc_str[lc_str.index(ltr) + shift]
else:
shifted_dict[ltr] = lc_str[lc_str.index(ltr)-26+shift]
for ltr in uc_str:
if uc_str.index(ltr) + shift < 26:
shifted_dict[ltr] = uc_str[uc_str.index(ltr) + shift]
else:
shifted_dict[ltr] = uc_str[uc_str.index(ltr)-26+shift]
return shifted_dict
def apply_shift(self, shift):
cipher = self.build_shift_dict(shift)
ciphertext = ""
for char in self.message_text:
if char in cipher:
ciphertext = ciphertext + cipher[char]
else:
ciphertext = ciphertext + char
return ciphertext
. 이 줄 중 하나가 코드의 138 줄입니까? 그렇다면 어떤 것을 말할 수 있습니까? – smarx
정확한 메시지를 줄 수 있습니까? 우리는 라인 138이 정확히 무엇인지 모릅니다. – idjaw
게시물을 편집하여 [mcve]를 제공해주십시오. –