In php, pack("V", $id);
It can change the "id" into binary with the 32 bits , unsigned, little endian format. How can we do the same this using python?
Another thing, I try the following code:
my_input = 10
binary_string = pack("<I", my_input)
print my_input
The output is :
▯▯▯
what is wrong with my code or my pycharm ?
To create a 32-bit unsigned little endian memory region in Python, use
struct.pack
just as you have:You can then store those bytes in a file like so: