I have a integer. Lets say,
var = 83 #less than 0xff
And I have a byte.
So let’s say I have byte b and I want to calculate the integer value of
b-=var #b as an integer value , possibly by eval(b)?
And then I want to turn it back into a byte, how can I do this in python?
If I understood the question, you can do:
where
'x'is your byte.If you’re on Python 3.x
Note
ord(b'x')is the same asb'x'[0]Another example (where the resulting byte is not printable and is shown in the
\x00form):