电码
摩尔斯电码中.与·要注意区分,
给出”-”与”—”、”.“与”·”的相互转换:
# -*- coding:utf-8 -*- def runnow(ciphertext): result='' l = list(ciphertext) for i in range(0,len(ciphertext)): if l[i] == '.': l[i] = '·' elif l[i] =='-': l[i]='—' else: l[i] = ciphertext[i] newS = ''.join(l) return newS ciphertext='-.-. -.-. -.. -.. -.. -.-. -.-. -.. -.-. -.. -..' print runnow(ciphertext)
相关阅读
#include <stdio.h>#include <string.h>//首先将摩斯电码的36个符号及其电码(1对应.,0对应-)记录在一个数组内char a[36][6] = { "