When/why should I use struct library in python to pack and unpack? -


i cant understand when should use pack , unpack functions in struct library in python? cant understand how use them? after reading it, understood used convert data binary. when run examples like:

>>> struct.pack("i",34) '"\x00\x00\x00' 

i cant make sense out of it. want understand purpose, how these conversions take place, '\x' , other symbols represent/mean , how unpacking work.

i cant understand when should use pack , unpack functions in struct library in python?

then don't have cause use them.

other people deal network , file formats have low-level binary packing, struct can useful.

however when run examples like:

>>> struct.pack("i",34) '"\x00\x00\x00' 

i cant make sense out of it.

the \x notation representing individual bytes of bytes object using hexadecimal. \x00 means byte's value 0, \x02 means byte's value 2, \x10 means that bytes value 16, etc. " byte 34, see " instead of \x22 in view of string, '\x22\x00\x00\x00' , '"\x00\x00\x00' same string

http://www.swarthmore.edu/natsci/echeeve1/ref/binarymath/numsys.html might background if level need understand numbers at.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -