输入格式编码好的Morse电文说明:用表示字符间隔用表示单词间隔输出格式明文字符串输入样例------------输出样例morse codeMorse编码字典可复制使用morse = # Letters a -b -c --d -e f -g -- h i j ---k --l -m --n - o ---p --q ---r -s t -u - v -w --x
code = input().split('/') message = ""
morse = { # Letters ".-": "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", # Numbers "-----": "0",".----": "1","..---": "2","...--": "3","....-": "4", ".....": "5","-....": "6","--...": "7","---..": "8","----.": "9", # Punctuation ".-...": "&",".----.": "'",".--.-.": "@","-.--.-": ")","-.--.": "(", "---...": ":","--..--": ",","-...-": "=","-.-.--": "!",".-.-.-": ".", "-....-": "-",".-.-.": "+",".-..-.": '"',"..--..": "?","-..-.": "/", }
for c in code: if c == '': message += ' ' else: message += morse[c]
print(message
原文地址: https://www.cveoy.top/t/topic/h6hH 著作权归作者所有。请勿转载和采集!