好的,所以我一直在努力解决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()