好的,所以我一直在努力解決DAYS的問題。我已經分配了一個代碼,將其標記爲「cipher.py」,用於導入加密的文本文件,使用「key.txt」進行解密,然後將解密後的信息寫入「decrypted.txt」之類的文件中。從密鑰文件製作解密器有點幫助?
一直收到encryptedWords = encryptedWords.replace(STR(encryptedFiles [I] [1]),STR(decryptedFiles [I] [0])) AttributeError的: '列表' 對象沒有屬性 '替換'
有什麼想法?
key = open("key.txt", "r")
encrypted = open("encrypted.txt","r")
decrypted = open("decrypted.txt", "w")
encryptedFiles = []
decryptedFiles = []
unencrypt= ""
for line in key:
linesForKey = line.split()
currentEncrypted = (line[0])
currentDecrypted = (line[1])
encryptedFiles.append(currentEncrypted)
decryptedFiles.append(currentDecrypted)
key.close()
##########################################
encryptedWords = []
encryptedString = ""
lines = encrypted.readlines()
for line in lines:
letter = list(line)
encryptedWords += letter
for i in range(len(encryptedWords)):
encryptedWords = encryptedWords.replace(str(encryptedFiles[i][1]),str(decryptedFiles[i][0]))
encrypted.close()
decrypted.write(encryptedWords)
decrypted.close()