how to init binary buffer in python
so, I read from DB binary field i.e. 'field1' to var Buf1, and then do so开发者_如何转开发mething like:
unpack_from('I', Buf1, 0)
so, all is ok. but question is how can I ini Buf1 without going to DB? I can get value from DB manually and init my var statically, but how? in DB field 'field1' I see something like '0x7B0500000100000064000000B80100006'. and how can I init valid binary buffer from it?
Just use pack or pack_into
it's the python's opposite of unpack_from.
See also that answer.
But you should elaborate on your question and give more sample code. The value you say you see from field is too large to read it into an integer. I wonder if you get the complete value.
精彩评论