文字列を入力して辞書から複数のキーを取得する方法が不思議でしたか?例えば、これは私のコードで、 "Underworldへようこそ"のようなものを印刷し、それを私の辞書の文字でエンコードしたいと思っています。辞書の複数のキー?
def main():
print("*********************************************************************************************")
print("What exactly is your use for this? Whatever, Enter a message because your hiding something...")
print("*********************************************************************************************")
userInput = input("Enter your message to encode: ")
userInput = userInput.lower()
# encoding dictionary
encoding = {"a":"b","b":"c","c":"d","d":"e","e":"f","f":"g","g":"h","h":"i","i":"j","j":"k","k":"l","l":"m","m":"n",
"n":"o","o":"p","p":"q","q":"r","r":"s","s":"t","t":"u","u":"v","v":"w","w":"x","x":"y",
"y":"z","z":"a"," ":"-"}
#userInput = encoding[key]
for key in encoding:
if (userInput == key):
print(encoding[key])
break
main()
そのラインで起こっていただきました!私は5だように 'CHR(ORD(「A」)+ 1) 'のような何かをするのではなく、辞書 –