且停停停停 发表于 2021-1-6 15:44:30

为什么这个加密程序写了个寂寞?菜鸡哭泣

s=list(input())
lst1=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
lst2=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
for i in s:
    if i in lst1:
      p=lst1.index(i)
      i=lst1[-p]
    elif i in lst2:
      k=lst2.index(i)
      i=lst2[-k]
    else:
      i=i
print("".join(s))

输出和输入一模一样{:10_266:}
>>> %Run 55.py
Hello World!
Hello World!
想把所有的a换成z,所有b换成y.......以此类推

jackz007 发表于 2021-1-6 18:06:06

本帖最后由 jackz007 于 2021-1-6 18:14 编辑

lst1=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
lst2=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
s = input()
t = ''
for i in range(len(s)):
    if s . isalpha():
      tx = lst1
      if s in lst2:
            tx = lst2
      t += tx[- tx . index(s) - 1]
    else:
      t += s
print(t)
      运行实况
D:\0002.Exercise\Python>python x.py
Hello World!
Svool Dliow!

Minecraft程序猿 发表于 2021-2-9 14:52:18

凯撒移位密码算法还是维吉尼亚算法?

XiaoPaiShen 发表于 2021-2-10 13:56:12

target = []
s=list(input("input the target world:"))
lst1=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
lst2=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
for i in s:
    if i in lst1:
      p=lst1.index(i)+1
      i=lst1[-p]      
    elif i in lst2:
      k=lst2.index(i)+1
      i=lst2[-k]
    else:
      i=i

    target.append(i)

print("".join(target))
页: [1]
查看完整版本: 为什么这个加密程序写了个寂寞?菜鸡哭泣