Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1234

Python • Re: Convert Integer to Hex Byte for use in I2C comms

$
0
0
You don't need to. It will happen automagically.

If you write hex code with

Code:

x=0x4f
that's exactly equivalent to

Code:

x=79
or octal code

Code:

x=0o117
Putting it all together

Code:

#!/usr/bin/python3x=0x4Fy=79z=0o117print ("X=:", x)print ("Y=:", y)print ("Z=:", z)

Statistics: Posted by DougieLawson — Mon Apr 29, 2024 6:18 pm



Viewing all articles
Browse latest Browse all 1234

Trending Articles