1
こんにちはすべて:)単純なテキストローテーション(ROT)でテキストをコードするスクリプトを作成しています。 スクリプトはうまく動作しますが、問題があります。また、[スペース、!、?、]のようなシンボルもすべて回転します。私はasciiテーブルを使って作業しています。文字?文字列から非文字を認識する方法
def rot13(input,key): #Function to code a text with caeser chyper.
if key > 25:
key = 25
elif key < 2:
key = 2
finaltext = ''
for letter in input:
num = ord(letter)
if (num + key) > 122: #If the final number is greater than 122..
x = (num + key) - 122
finaltext += chr(x + ord('a') - 1)
elif((num + key <= 122)):
finaltext += chr(num + key)
print(finaltext)
感謝を:)! – prossellob