# Morsecoder **Repository Path**: lemonix/morsecoder ## Basic Information - **Project Name**: Morsecoder - **Description**: 一个关于摩斯密码编码与译码的库 - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: https://lemonix.rthe.xyz/morsecoder.html - **GVP Project**: No ## Statistics - **Stars**: 7 - **Forks**: 1 - **Created**: 2021-04-23 - **Last Updated**: 2022-07-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: 工具, 工具包, 摩斯密码, 摩尔斯码 ## README # Morsecoder > By Lemonix ![Python 图标](https://img.shields.io/badge/Python-3.6%2B-brightgreen?style=for-the-badge&logo=appveyor) ![Build 图标](https://img.shields.io/badge/Build-Passing-orange?style=for-the-badge&logo=appveyor) ![License 图标](https://img.shields.io/badge/License-Apache-brightgreen?style=for-the-badge&logo=appveyor) *** ## 介绍 一个关于摩斯密码编码与译码的库 **Lastest version: v1.2** **v1.2更新内容** - 修复严重内存溢出Bug - 减少冗余try..except操作,提升性能 - 重构部分函数 **v1.1更新内容** - 重构内部方法,减少内存消耗 ## 使用教程 - 主要方法 ```python get_encode(string, [**opt]) get_decode(string, [**opt]) # opt为可选参数,有sep long short三个参数 # sep为分隔符,long为长字符,short为短字符 # sep默认为'/',long默认为'-',short默认为'.' # 在get_encode中,sep参数没有用,因为用不到 # 两个函数返回迭代器,内容用for循环获取 ``` - 导入 ```python from morsecoder import * ``` - 编码 ```python for value in get_encode('Hello.World', long='*', short='.'): # 空格用.代替 print(value, end='/') # end为分隔符 print() # 空一行结束end ``` **Output:** ```bash python test.py ...././.*../.*../***/.*.*.*/.**/***/.*./.*../*../ ``` - 解码 ```python for value in get_decode('...././.-../.-../---/.-.-.-/.--/---/.-./.-../-../'): # 使用默认参数 print(value, end='') print() ``` **Output:** ```bash python test.py HELLO.WORLD ``` *更多测试见源码根目录中的test.py* **** ## 参与贡献 Lemonix(开发与测试) [Lemonix-Gitee](https://gitee.com/lemonix) [Lemonix-Github](https://github.com/lemonix-xxx) ## 你知道吗 Morsecoder第一个版本:RtMorsecoder于2021/1/11 17:19发布 Morsecoder的灵感来源于Sherlockcxk的C#项目Morsecoder