用户:五年七班郝睿茗查看:0 回复:0 评论:0 创建时间:2023-03-04T14:01:32
【作品展示】

【作品介绍】
这是一款摩斯电码译码器,只需点击运行,在输入端输入摩斯电码(注意:要用空格间隔开),再点击OK或enter就可以译码了。后续还会推出字母和数字的转摩斯电码器
【作品源代码】
from turtle import *
title('摩斯密码破译器')
hideturtle()
speed(0)
bgcolor('black')
pencolor('white')
penup()
goto(-170,-290)
write('M',font=('宋体',500,'normal'))
def m():
title('摩斯密码输入端')
try:
while True:
m()
ans1 = textinput('摩斯密码输入端', '请输入摩斯密码(用空格隔开)')
ans1 = ans1.split(' ')
list2=[]
for i in ans1:
if i == '.-':
list2.append('A')
if i == '-...':
list2.append('B')
if i == '-.-.':
list2.append('C')
if i == '-..':
list2.append('D')
if i == '.':
list2.append('E')
if i == '..-.':
list2.append('F')
if i == '--.':
list2.append('G')
if i == '....':
list2.append('H')
if i == '..':
list2.append('I')
if i == '.---':
list2.append('J')
if i == '-.-':
list2.append('K')
if i == '.-..':
list2.append('L')
if i == '--':
list2.append('M')
if i == '-.':
list2.append('N')
if i == '---':
list2.append('O')
if i == '.--.':
list2.append('P')
if i == '--.-':
list2.append('Q')
if i == '.-.':
list2.append('R')
if i == '...':
list2.append('S')
if i == '-':
list2.append('T')
if i == '..-':
list2.append('U')
if i == '...-':
list2.append('V')
if i == '.--':
list2.append('W')
if i == '-..-':
list2.append('X')
if i == '-.--':
list2.append('Y')
if i == '--..':
list2.append('Z')
if i=='.----':
list2.append('1')
if i=='..---':
list2.append('2')
if i=='...--':
list2.append('3')
if i=='....-':
list2.append('4')
if i=='.....':
list2.append('5')
if i=='-....':
list2.append('6')
if i=='--...':
list2.append('7')
if i=='---..':
list2.append('8')
if i=='----.':
list2.append('9')
if i=='-----':
list2.append('0')
print(list2)
except :
print('欢迎下次使用')
done()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn