摩尔斯电码中.与·要注意区分,
给出”-”与”—”、”.“与”·”的相互转换:
python代码如下:
# -*- 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)