[Python] How can I byte-swap a 32-bit integer in Python?

Discussão em 'Python' iniciado por Stack, Agosto 3, 2025.

  1. Stack

    Stack Membro Participativo

    Take this example:

    i = 0x12345678
    print("{:08x}".format(i))
    # Shows 12345678
    i = swap32(i)
    print("{:08x}".format(i))
    # Should print 78563412


    What would be the swap32-function()? Is there a way to byte-swap an int in Python, ideally with built-in tools?

    Continue reading...

Compartilhe esta Página