Beerina
Sarcastic Conqueror of Notions
- Joined
- Mar 3, 2004
- Messages
- 34,334
When I read some binary data with pySerial, I get an str that contains elements that, when printed, look like this:
'\xc0'
That itself is a str. How do I turn it back into a number so I can do math on it?
o int( '\xc0' ) chokes
o The binascii library is useless as it can't handle this in any of its format conversions.
As these are bytes, I could conceivably do 256-sized lookup table, but that's obviously stupid to do.
I am not super familiar with Python, yet, having only started a few days ago.
The result should be amenable to simple math, like adding or subtracting 3.
'\xc0'
That itself is a str. How do I turn it back into a number so I can do math on it?
o int( '\xc0' ) chokes
o The binascii library is useless as it can't handle this in any of its format conversions.
As these are bytes, I could conceivably do 256-sized lookup table, but that's obviously stupid to do.
I am not super familiar with Python, yet, having only started a few days ago.
The result should be amenable to simple math, like adding or subtracting 3.