0

What is the use of the ord() function?

I've looked it up and still don't seem to understand, it's stated that it returns the integer value of the character or something... maybe someone can give a simple example where it is used

11th Dec 2018, 9:43 AM
Joseph Ojo
Joseph Ojo - avatar
4 ответов
+ 1
https://docs.python.org/3/library/functions.html#ord Yes it returns an integer value represent the character in unicode. Why would anyone use this, because its easier to calculate this way for cipher or something else. https://code.sololearn.com/cI6l7LCedFXW/?ref=app here i use those value to modify each character binary using another as reference on how much should i shift its binary.
11th Dec 2018, 9:52 AM
Taste
Taste - avatar
0
Taste I don't really understand the output of your code, maybe after reading on binary shifting, I might understand
11th Dec 2018, 4:56 PM
Joseph Ojo
Joseph Ojo - avatar
0
Simpler example will be caesar cipher for i in range(len(txt)): c=ord(txt[i])+ord(key) if(c>ord('z')): c=ord('a')+(c-ord('z')+1) print(chr(c))
11th Dec 2018, 4:59 PM
Taste
Taste - avatar
0
I have a little understanding now Taste , and you opened me up to another world (cryptography), thank you
11th Dec 2018, 6:09 PM
Joseph Ojo
Joseph Ojo - avatar