So I have this code:
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("")
My question is: How can I make an opposite program, so it accepts the bunch of junk letters and converts it to text that makes sense?
Example: If I type something like "aaaaaaa" in this program it will convert it to something like "mapma&)at7ar8a2ga-ka*"
In this new program I want to type "mapma&)at7ar8a2ga-ka*" and get output "aaaaaaa".
Does this work for you?:
s="1a23a45a6"
print(s[1::3]) # aaa
这样做: initial_str = random_str[1:-1:3]
,其中random_str是带垃圾的字符串
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.