Python Programming encoding numbers to letters -


I am trying to create a code that is 00 = a 01 = b and it should be done, for example, Str2numsp ('i like python' 'string' 3452110810045241241907141353 'should return.

Do you want to use any number on 0 or you can use the unicode value of each character such as:

ord ("a ") -> 97, ord (" b) -> 98 .. etc

Then you

  myString = "I like python"  

and use a list comprehension

  [ord (i) in [myrring]  

Which output

  [73, 32, 108, 105, 107, 101, 32, 80, 121, 116, 104, 111, 110]  

then insert them as strings

  ".include ([str (ord (i)) in iString )  

returns the final output

  '73321081051071013280121116104111110'  

If you want to start with zero < Code> 'a' , you can always decrease 97 (which is 'A') from each code, But you should be careful about special characters (spaces), punctuation marks, etc.).


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -