标题:请教!下面的代码为什么不能将摩尔斯电码转换为英语原文?
只看楼主
yitian1368
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2022-12-1
结帖率:0
已结贴  问题点数:20 回复次数:1 
请教!下面的代码为什么不能将摩尔斯电码转换为英语原文?
code=["._","_...","_._.","_..",".",".._.","__.","....","..",".___","_._","._..","__","_.","___",".__.","__._","._.","...","_",".._","..._",".__","_.._","_.__","__.."]
message=input("请输入电报:")
message+=""
chars=""
output=""
for letter in message:
    if letter!="":
        chars=chars+letter
    else:
        for index in range(26):
            if code[index]==chars:
                output+=chr(ord('A')+index)
        chars=""
print("英语原文是:",output)
            
搜索更多相关主题的帖子: 代码 英语 output index letter 
2022-12-01 14:45
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:版主
威 望:422
帖 子:13681
专家分:53296
注 册:2012-10-18
得分:20 
回复 楼主 yitian1368
输入报文是啥格式的   码与码之间  用什么隔开

程序代码:
code=["._","_...","_._.","_..",".",".._.","__.","....","..",".___","_._","._..","__","_.","___",".__.","__._","._.","...","_",".._","..._",".__","_.._","_.__","__.."]
passwd='._   _...   _._.   _..   .   .._.   __.   ....   ..   .___   _._   ._..   __   _.   ___   .__.   __._   ._.   ...   _   .._   ..._   .__   _.._   _.__   __..'
source=""
for x in passwd.split():
    if x in code:
        source+=chr(ord("A")+code.index(x))
print(source)        

DO IT YOURSELF !
2022-12-07 14:22



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-510833-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.052081 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved