| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 531 人关注过本帖
标题:请教!下面的代码为什么不能将摩尔斯电码转换为英语原文?
只看楼主 加入收藏
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
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册: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
快速回复:请教!下面的代码为什么不能将摩尔斯电码转换为英语原文?
数据加载中...
 
   



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

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