我正在编写一个文本编码器/加密器(全部由我自己),但我不明白如何在字符串中附加和替换字符:-/
代码:
import os, sys, random
dig = 0
text_encoded = ""
text = ""
try:
if os.path.isfile(sys.argv[1]) == True:
with open(sys.argv[1], "r") as text:
text = text.readlines()
except:
pass
if text == "":
print("Write the text to encode")
text = input()
text = text.split()
for _ in range(len(text)):
text_encoded = text[dig].replace("qwertyuiopasdfghjklzxcvbnm ", "mnbvcxzlkjhgfdsapoiuytrewq@")
dig = dig+1
print("Your encoded text is:\n"+text_encoded)
这是一些输出:
Write the text to encode
lo lolo lol lol
Your encoded text is:
lol
如果你能以任何方式帮助我,谢谢:-)
MYYA
拉风的咖菲猫
慕侠2389804
相关分类