我已經成功設法創建了一個代碼,它使用程序中早些時候隨機生成的偏移因子對文本文件進行加密,但我不知道如何在不加密的情況下留下空間。加密文本文件,但留下的空間?
text_file = open("sample.txt", "r")
characters = []
for line in text_file:
for c in line:
characters.append(c)
text_ascii = []
text_number = 0
new_number = 0
cipher_text = ""
for i in characters:
if i not in (" "):
text_ascii = ord(i)
text_number = text_ascii + offset_factor
if text_number > 126:
text_number = text_number - 94
new_number = chr(text_number)
cipher_text = cipher_text + new_number
print (cipher_text)
我現在的代碼沒有加密空格或者根本不包含它們。
文本文件的內容(稱爲「sample.txt的」,所有在同一行)是:
某處在拉曼恰,在他的名字我不在乎記住一個地方,君子不活很久以前,那些在架子上有長矛和古盾牌的人中,有一個人爲了比賽而保留了一個瘦骨n and和一隻灰狗。
如果我不在(「‘):=>若i =!’」: –