How to get the decimal value of a character from the ascii table in Python? I have the letter 'A' Russian, I want to get 192.
- I could not find anything, I suffer about this hour with this question ... - danil sokolov
- 2Ps. (classic) ASCII seven-bit coding and the code 192 is simply not there. You are asking about Windows-1251- - Enikeyschik
- Let’s say so, then how can you still pull out this treasured number 192 using the letter A? - danil sokolov pm
|
1 answer
ord(ch) displays the character code ch .
a = "А" b = a.encode('windows-1251') # переводим в Windows-1251 print (ord(b)) Reverse operation (print a character using its numeric code) - chr(num) :
print (chr(192)) # выведет не А, а À, т.к. по умолчанию используется юникод - Probably worth a break, three lines solved all my problems, thank you so much! - danil sokolov
|
