Advertisement
JachyHm

Morse code online converter

Jan 27th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.62 KB | None | 0 0
  1. zapis = open('preloz.mors','w')
  2. preloztext = '••--•• /'
  3. x = ' '
  4. mezera = ''
  5. text=''
  6. pismenko=''
  7. pismenkoM=''
  8. prevX = ''
  9. dict = {"•-":'a',".-":'a',"-•••":'b',"-...":'b',"-•-•":'c',"-.-.":"c","-••":'d',"-..":"d","•":'e',".":"e","••-•":'f',"..-.":"f","--•":'g',"--.":"g","••••":'h',"....":"h","••":'i',"..":"i","•---":'j',".---":"j","-•-":'k',"-.-":"k","•-••":'l',".-..":"l","--":'m',"-•":'n',"-.":"n","---":'o',"•--•":'p',".--.":"p","--•-":'q',"--.-":"q","•-•":'r',".-.":"r","•••":'s',"...":"s","-":'t',"••-":'u',"..-":"u","•••-":'v',"...-":"v","•--":'w',".--":"w","-••-":'x',"-..-":"x","-•--":'y',"-.--":"y","--••":'z',"--..":"z","/":' ',"••--••":'?',"..--..":"?","--..--":",","--••--":",","---••":"8","••---":"2","-•-•-•":";","-----":"0","•----":"1","-•--•-":"(","--•••":"7","---•••":":","•••••":"5","-••••-":"-","--•••-":"!","----•":"9","•••--":"3","-••-•":"/","-••••":"6","••••-":"4","-•••-":"=","•--•-•":"@"};
  10. zapis.write(str(preloztext))
  11. zapis.close()
  12. zdroj = open('preloz.mors','r')
  13. while(x!=''):
  14.     x = zdroj.read(1)
  15.     pismenko=''
  16.     if (x=='/'):
  17.         if (pismenkoM!=''):
  18.             pismenko = dict[pismenkoM]
  19.             pismenkoM=''
  20.             text = text + pismenko
  21.         mezera=mezera+'/'
  22.     elif (x!=' '):
  23.         pismenkoM = pismenkoM + x
  24.         prevX = x
  25.     if (x!='/' and x!=' '):
  26.         mezera=''
  27.     if (mezera == '//'):
  28.         text = text + ' '
  29.         mezera=''
  30. zdroj.close()
  31. print(text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement