【发布时间】:2021-10-24 06:26:59
【问题描述】:
我是 python 新手,正在做一个测试程序,用符号替换给定文本中的所有字母。
def encrypted(request):
text = request.GET['text']
text = text.replace("a", "#.")
text = text.replace("b", "##.")
text = text.replace("c", "###.")
text = text.replace("d", "####.")
text = text.replace("e", "#####.")
text = text.replace("f", "######.")
etc...
return render(request, 'encrypted.html', {'text': text})
我已经做到了,但我尝试以相同的方式反转它,但它不起作用。
def decrypted(request):
ftext = request.GET['text']
ftext = ftext.replace("#.", "a")
ftext = ftext.replace("##.", "b")
ftext = ftext.replace("###.", "c")
ftext = ftext.replace("####.", "d")
ftext = ftext.replace("#####.", "e")
etc...
return render(request, 'decrypted.html')
所以文本根本不会出现在页面上。
<html lang="en">
<head>
<meta charset="UTF-8">
<title>yCrypt</title>
</head>
<body>
TEXT DECRYPTION: {{ftext}}
</body>
</html>
我想知道为什么它没有显示任何代码问题。也许有更简单的方法可以实现这一点?
【问题讨论】: