PyMorse
Module that can convert text to Morse Code or decode it back to uppercase text.
How to use:
Simply download and add morse_code_pairs.py and morse_converter.py to your working directory and then import morse_encoder or morse_decoder to your python script and use them.
Example code:
from morse_converter import morse_encoder, morse_decoder
import pyinputplus
def main():
text_to_encode = pyinputplus.inputStr(
prompt="Please enter the text which you want to be converted into Morse Code:"
)
encoded_text = morse_encoder(text_to_encode)
print(f"Your text after Morse encoding is:\n{encoded_text}")
print(f"Your original text is:\n{text_to_encode}")
print(f"And the decoding is:\n{morse_decoder(encoded_text)}")
if __name__ == '__main__':
main()
Morse Code Table API
If you need the Morse Code table for your coding projects, you can send a GET request to the endpoint https://www.hossein.codes/morse-code/table and you will receive back the table in JSON format.
Sources:
The Morse Code table has been compiled by combining the resources from the following websites: