用户:
降临派_深渊之影查看:5 回复:7 评论:5 创建时间:2023-07-23T19:36:49
【作品展示】

【作品介绍】
摩斯密码编码器,可以把字母转换成摩斯密码
【作品源代码】
global list1
list1 = ['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', '', '']
list2 = ['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', '', '']
list3 = ['.-', '-...', '-.-.', '-..', '.', '..-.', '--.', '....', '..', '.---', '-.-', '.-..', '--', '-.', '---', '.--.', '--.-', '.-.', '...', '-', '..-', '...-', '.--', '-..-', '-.--', '--..', '', '']
e = ''
def f1():
global d, e
d = 0
while (not (a[c] is list1[d])):
d += 1
e = ((e + ' ') + list3[d])
while True:
e = ''
a = input('要编码的字符').lower()
c = 0
for __count in range(len(a)):
f1()
c = (c + 1)
print(e)
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn让你们见识见识:
import easygui
#开始进入Python的世界
if (easygui.ynbox('编码解码', '摩斯密码一体机',('编码', '解码')) == 1):
import time as t
# 开始进入Python的世界
# 导入数据
list_symbol = ['~', '!', '@', '#', '$', '\%', '^', '&', '*', '(', ')', '-------', '=', '+', '|', '{', '}', '[', ']', ';', ':', "'", '<', '>', ',', '。', '?', ' ', '.-', '-...', '-.-.', '-..', '.', '..-.', '--.', '....', '..', '.---', '-.-', '.-..', '--', '-.', '---', '.--.', '--.-', '.-.', '...', '-', '..-', '...-', '.--', '-..-', '-.--', '--..', '.----', '..---', '...--', '....-', '.....', '-....', '--...', '---..', '----.', '-----']
list_litter = ['~', '!', '@', '#', '$', '\%', '^', '&', '*', '(', ')', '-------', '=', '+', '|', '{', '}', '[', ']', ';', ':', "'", '<', '>', ',', '。', '?', ' ', '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', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
list_py = []
list_pyc = []
# 验证无误
if (len(list_symbol) == len(list_litter)):
print('确认无误,可以使用。')
elif (len(list_symbol) != len(list_litter)) :
print('错误,请维修。(数据库的问题)')
print('错误码:',len(list_symbol))
print('错误码:',len(list_litter))
t.sleep(99999)
else :
print('其他错误')
t.sleep(99999)
# 查询翻译内容
a = input('要加密的内容,请翻译成英文,只支持部分符号(空格),留数字和英文,大写换小写。:')
# 开始翻译
z = 0
for f in range(len(a)):
list_py.append(a[z])
z = (z + 1)
for b in list_py:
for c in list_litter:
if (c == b):
list_pyc.append(list_symbol[list_litter.index(c)])
jieguo = '/'.join(list_pyc)
# 结果汇报
print('输入:')
print(a)
print('结果:')
print(jieguo)
else :
print('-----------------------------------')
print('| 作品原创 |')
print('| 禁止喷子 |')
print('| 2023/8/1 |')
print('| 星期二 |')
print('| 9:30 |')
print('| ********************************|')
print('-----------------------------------')
import time as t
# 开始进入Python的世界
# 导入数据
list_symbol = ['~', '!', '@', '#', '$', '\\\%', '^', '&', '*', '(', ')', '-------', '=', '+', '|', '{', '}', '[', ']', ';', ':', "'", '<', '>', ',', '。', '?', ' ', '.-', '-...', '-.-.', '-..', '.', '..-.', '--.', '....', '..', '.---', '-.-', '.-..', '--', '-.', '---', '.--.', '--.-', '.-.', '...', '-', '..-', '...-', '.--', '-..-', '-.--', '--..', '.----', '..---', '...--', '....-', '.....', '-....', '--...', '---..', '----.', '-----']
list_litter = ['~', '!', '@', '#', '$', '\\\%', '^', '&', '*', '(', ')', '-------', '=', '+', '|', '{', '}', '[', ']', ';', ':', "'", '<', '>', ',', '。', '?', ' ', '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', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
list_py = []
list_pyc = []
# 验证无误
if (len(list_symbol) == len(list_litter)):
print('确认无误,可以使用。')
elif (len(list_symbol) != len(list_litter)) :
print('错误,请维修。(数据库的问题)')
print('错误码:',len(list_symbol))
print('错误码:',len(list_litter))
t.sleep(99999)
else :
print('其他错误')
t.sleep(99999)
# 查询翻译内容
temp = input('把编码器的结果粘贴到这里来:')
a = temp.split('/')
# 开始翻译
z = 0
for f in range(len(a)):
list_py.append(a[z])
z = (z + 1)
for b in list_py:
for c in list_symbol:
if (c == b):
list_pyc.append(list_litter[list_symbol.index(c)])
# 结果汇报
print('输入:')
print(temp)
print('结果:')
for jieguo in list_pyc:
print(jieguo)
点赞0
评论