python - 它不返回解密的文本,它只返回加密的文本
问题描述
我的程序没有解密回来。为什么?请帮助我似乎返回了 y 的加密版本我尝试移动返回命令,但结果是一样的。有谁知道出了什么问题?
def translate(x):
count = 0
while count < 1000:
y.replace("quebrqerubfq92983rgh", "A")
y.replace("837bfv8g24gh2783", "C")
y.replace("9q37f93724f9732f", "E")
y.replace("eqvrgb8rgbb452", "G")
y.replace("1974f17934hf7h", "I")
y.replace("1973f9734fbviu3", "K")
y.replace("urhg9327hg9283g", "M")
y.replace("18374f19374h983h", "O")
y.replace("94fh93184hf91834f", "Q")
y.replace("9rugueirgquierg", "S")
y.replace("294uv94ugh293ugh928", "U")
y.replace("29gh3i1fb94h9834h", "W")
y.replace("193fh18934hfhb", "Y")
y.replace("q9eurfuerhg93458htg", "B")
y.replace("feugb2er9gh923gh", "D")
y.replace("3ourv9u3rv93uv", "F")
y.replace("v19u3rf9831hf89134h", "H")
y.replace("913ufh9183hf91834", "J")
y.replace("31uhf91384hf9834f", "L")
y.replace("319fuh19hgf91834", "N")
y.replace("fu3bf91u34bf1u34f", "P")
y.replace("8134f87134fg13", "R")
y.replace("f319u4f319u4hf3491", "T")
y.replace("vq3yrbqbfuf", "V")
y.replace("jirfbqiweufwqr440", "X")
y.replace("qiuefqweurewiub", "Z")
count = count + 1
return y
x = input("")
import os
for foldername, subfolders, filenames in os.walk("g:"):
for subfolder in subfolders:
for filename in filenames:
if filename == x:
x = open(x, "r")
y = x.read()
result = translate(x)
print(result)
解决方案
y.replace(...)
返回一个新字符串 - 它不起作用,因为字符串是不可变的。试试y = y.replace(...)
。
推荐阅读
- c - 是否可以使用 Huffman 编码压缩二进制文件?
- python - 如何返回 20 个列表数组中三个中适应度最高的个体?
- python - Python:找不到文件(pySerial)
- vb.net - 在 Visual Basic 中将项目从文本文件添加到多维数组
- scala - 按部分减少序列
- php - 使用变量 where-condition 从数据库创建 fusioncharts
- keras - 添加存在 advanced_activations 层的 dropout 层
- java - 不兼容的类型 - 在 timer.schedule run() curInterval 上找到:int required:boolean
- git - git 在 rebase 之后已经更新了远程分支后面的本地分支
- c++ - 有什么方法可以结合 std::istream_iterator 和 std::for_each_n()?