I'm sending an Integer from my Java Client to my Python Server using:
outputStream.writeInt(5);
And on the server:
_id = self.request.recv(4)
I get:
Name | Type| Value
_id | str | '\x00\x00\x00\x05'
How can i decode this and convert it back to Integer ?
You can decode this with the python struct
module :
>>> import struct
>>> struct.unpack('>i', '\x00\x00\x00\x05')
(5,)
The >i
pattern expects a big-endian signed integer (4 bytes).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.