c - How is the conversion in the python struct module done? -


i need unpack information in python c structure, doing following code:

struct.unpack_from('>i', file.read(4))[0] 

and afterwards, writing changed values back:

new_value = struct.pack('>i', 008200) file.write(new_value) 

a few examples: 008200 returns syntaxerror: invalid token. 000010 written into: 8 000017 written into: 15 000017 returns syntaxerror.

i have no idea kind of conversion is. kind of great.

this invalid python code , not related struct module. in python, numbers starting 0 octal (base 8). so, python tries decode 008200 in octal '8' isn't valid. assuming wanted decimal, use 8200. if wanted hex, use 0x8200.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -