0

I've performed the following in the Python 3.7.0 interpreter:

>>> test = pack('<8s', b'\x00\x01\x00\x02\x00\x00\x00\x03')
>>> test
b'\x00\x01\x00\x02\x00\x00\x00\x03'
>>> type(test)
<class 'bytes'>
>>> unpack('>8s', test)
(b'\x00\x01\x00\x02\x00\x00\x00\x03',)
>>> unpack('<8s', test)
(b'\x00\x01\x00\x02\x00\x00\x00\x03',)

Expected behavior: When I run unpack with big endian specified, the unpack returns the bytes in the reverse order from the original input which is packed with little endian.

Actual behavior: The bytes never change order at all.

the_endian
  • 2,259
  • 1
  • 24
  • 49
  • 1
    Endianness won't make any difference to a string of bytes. Try it with some integers or floats. – Fred Larson Apr 26 '19 at 19:10
  • 1
    Possible duplicate of [Is it true that endianness only affects the memory layout of numbers,but not string?](https://stackoverflow.com/questions/5804824/is-it-true-that-endianness-only-affects-the-memory-layout-of-numbers-but-not-str) – Fred Larson Apr 26 '19 at 20:01

0 Answers0