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

MicroPython • Re: I2C 24C256 Eeprom micropython libs and example code please?

$
0
0
b'\x07\x11\xff\t\r\x07\xf4r'
That may look weird, but it's a bytes object. Python uses a compact mix of hex, escape codes and printable characters. One of the nice things about a bytes object is you can access them as a list:

Code:

print(b'\x07\x11\xff\t\r\x07\xf4r'[3])9for i in b'\x07\x11\xff\t\r\x07\xf4r':     print(i, type(i))7 <class 'int'>17 <class 'int'>255 <class 'int'>9 <class 'int'>13 <class 'int'>7 <class 'int'>244 <class 'int'>114 <class 'int'>
Note that the value is cast to an int type. This is generally more useful than if it stayed as a byte, but sometimes requires care putting the value back.

Hope you're feeling better. Hospital trips are no fun.

Statistics: Posted by scruss — Sat Aug 30, 2025 5:51 pm



Viewing all articles
Browse latest Browse all 8034

Trending Articles