簡體   English   中英

代碼打印“n”而不是“if”。 我不知道為什么會這樣

[英]code printing "n" instead of "if". I don't know why this is happening

(我的問題)當我在這個程序中輸入“ad”時,它輸出“n”。 我想將字母表中的每個字符向前移動 5 個字符(“ad”將變為“fi”),然后反轉結果(“fi”將變為“if”)。

print("This program is meant to allow users to securely store text information through the use of different forms of security measures.")




IA=input("Enter the information you would like stored:")
#creating/opening a text file and inserting/storing the user input
a=open("user_input","wt")
a.write(IA)
a=open("user_input","rt")
print(a.read())
a.close()


print("Enter the different ways you would like the information entered. It is recommended you use more than just 1 of these methods for security")
SFA=input("Would you like the information to be stored using encryption?(Answer in 'yes' or 'no'):")

#creating a list
thislist = ["SFA","SFB","SFC","SFD","SFE"]
if SFA:"yes"
RT=IA




RT=RT.replace("f","0").replace("a",chr(ord("a")+5)).replace("f","1").replace("0","f")
RT=RT.replace("g","2").replace("b",chr(ord("b")+5)).replace("g","3").replace("2","g")
RT=RT.replace("h","4").replace("c",chr(ord("c")+5)).replace("h","5").replace("4","h")
RT=RT.replace("i","6").replace("d",chr(ord("d")+5))
RT=RT.replace("i","7").replace("6","i").replace("j","8").replace("e",chr(ord("e")+5))
RT=RT.replace("j","9").replace("8","j").replace("k","10").replace("f",chr(ord("f")+5))
RT=RT.replace("k","11").replace("l","12").replace("g",chr(ord("g")+5)).replace("10","k").replace("3","g")
RT=RT.replace("l","13").replace("m","14").replace("h",chr(ord("h")+5)).replace("5","h").replace("12","l")
RT=RT.replace("m","15").replace("n","16").replace("14","m").replace("i",chr(ord("i")+5))
RT=RT.replace("n","17").replace("16","n").replace("o","18").replace("j",chr(ord("j")+5))
RT=RT.replace("o","19").replace("18","o").replace("p","20").replace("k",chr(ord("k")+5)).replace("11","k")
RT=RT.replace("p","21").replace("20","p").replace("q","22").replace("l",chr(ord("l")+5)).replace("13","l")
RT=RT.replace("q","23").replace("22","q").replace("r","24").replace("m",chr(ord("m")+5)).replace("15","m")
RT=RT.replace("r","25").replace("24","r").replace("s","26").replace("n",chr(ord("n")+5)).replace("17","n").replace("7","i")
RT=RT.replace("s","27").replace("26","s").replace("t","28").replace("o",chr(ord("o")+5)).replace("19","o").replace("9","j")
RT=RT.replace("t","29").replace("28","t").replace("u","30").replace("p",chr(ord("p")+5)).replace("21","p")
RT=RT.replace("u","31").replace("30","u").replace("v","32").replace("q",chr(ord("q")+5)).replace("23","q")
RT=RT.replace("v","33").replace("32","v").replace("w","34").replace("r",chr(ord("r")+5)).replace("25","r")
RT=RT.replace("w","35").replace("34","w").replace("x","36").replace("s",chr(ord("s")+5)).replace("27","s")
RT=RT.replace("x","37").replace("36","x").replace("y","38").replace("t",chr(ord("t")+5)).replace("29","t")
RT=RT.replace("y","39").replace("38","y").replace("z","40").replace("u",chr(ord("u")+5)).replace("31","u")
RT=RT.replace("z","41").replace("40","z").replace("a","42").replace("v",chr(ord("v")-21)).replace("33","v")
RT=RT.replace("a","43").replace("42","a").replace("b","42").replace("w",chr(ord("w")-21)).replace("35","w").replace("43","a")
RT=RT.replace("b","45").replace("44","b").replace("c","44").replace("x",chr(ord("x")-21)).replace("37","x").replace("45","b")
RT=RT.replace("c","47").replace("46","c").replace("d","46").replace("y",chr(ord("y")-21)).replace("39","y").replace("47","c")
RT=RT.replace("d","49").replace("48","d").replace("e","44").replace("z",chr(ord("z")-21)).replace("41","z").replace("49","d").replace("1","f")
rtback = RT[::-1]
print(rtback)

問題是因為你不知道什么時候是 1 和 7 或者什么時候是 17。你必須拆分你的字母並單獨操作它們。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM