我正在尝试将纯文本转换为密文:
plaintext ='保卫城堡的东墙'
密文:'efgfoe uif fbtu xbmm pg uif dbtumf'
p = plaintext.split(' ')
for i in p:
i2=[i]
for word in i2:
for letter in word:
inc=ord(letter)+1
print(chr(inc),end='')
我得到的解决方案是:
efgfoeuiffbtuxbmmpguifdbtumf
如何将相关空格包括为纯文本?
就像:'efgfoe uif fbtu xbmm pg uif dbtumf'
答案 0 :(得分:0)
这应该做
plaintext = 'defend the east wall of the castle'
p = plaintext.split(' ')
wholecipher=[]
for word in p:
word_cipher=''
for letter in word:
inc=ord(letter)+1
word_cipher += chr(inc)
wholecipher.append(word_cipher)
print(' '.join(wholecipher))