user1595754
user1595754

Reputation: 81

python's standard bit size in struct module

In http://docs.python.org/library/struct.html, it says "<" represents little-endian mode in standard size. I checked on this website and it says the standard size is 16 bits.

WHY 16 BITS?

Is there anyway to change it to 8-bit and still using the little-endian?

Best regards!

question is still OPEN!

I know LSB or MSB describe the data organization based on bytes. The questions is the standard size is 16-bit, so python read the data based on the standard size then based on the LSB or MSB. If I use

And, if the standard size is 16-bit long, then why if I use ">h", it actually give the correct answer as the standard size is 8-bit?

Upvotes: 0

Views: 320

Answers (1)

Joe
Joe

Reputation: 47609

Big endian and little endian aren't really meaningful for a byte. Endianness describes the order of bytes in a multi-byte type.

That said, you can use "<B" as your type. That gives you little-endian 8 bits.

Upvotes: 2

Related Questions