Today i will talk about the python built-in function ord() .
For example, I receive raw data from serial or tcp device,the data always be the array of binary.When you print it to console,it shows like b’\x01\xe5′ and so on.
To convert this data to int like below.
raw_data = b'\x01\xe5' print(int(ord(raw_data)),16)
Thats it! very simple!OK thanks for reading see you soon!