所以我有这段代码:
def myprogram():
import string
import random
import getpass
inputpasswd = getpass.getpass("Password: ")
passwd = ("I<3StackOverflow")
if passwd == inputpasswd:
qwerty = input("Type something: ")
def add_str(lst):
_letters = ("1","2","3","4","5","6","7","8","9","0","q","w","e","r","t","z","u","i","o","p","a","s","d","f","g","h","j","k","l","y","x","c","v","b","n","m","!","#","$","%","&","/","(",")","=","?","*","+","_","-",";"," ")
return [''.join(random.sample(set(_letters), 1)) + letter + ''.join(random.sample(set(_letters), 1))for letter in lst]
print(''.join(add_str(qwerty)))
input("")
else:
print("Wrong password")
input("")
我的问题是:如何制作相反的程序,以便接受一堆垃圾字母并将其转换为有意义的文本?
实施例: 如果我在这个程序中键入类似“aaaaaaa”的内容,它会将其转换为“mapma&amp;”at7ar8a2ga-ka *“
在这个新节目中,我想输入“mapma&amp;”at7ar8a2ga-ka *“并输出”aaaaaaa“。
答案 0 :(得分:0)
这对你有用吗?:
s="1a23a45a6"
print(s[1::3]) # aaa
答案 1 :(得分:0)
这样做:initial_str = random_str[1:-1:3]
,其中random_str是带垃圾的字符串