简体   繁体   English

这个'\\ x00 \\ x00 \\ x00 \\ x05'的编码是什么?

[英]What encoding is this '\x00\x00\x00\x05'?

I'm sending an Integer from my Java Client to my Python Server using: 我正在使用以下命令从我的Java客户端向我的Python服务器发送一个Integer:

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 ? 我该如何解码并将其转换回Integer?

You can decode this with the python struct module : 您可以使用python struct模块对此进行解码:

>>> import struct
>>> struct.unpack('>i', '\x00\x00\x00\x05')
(5,)

The >i pattern expects a big-endian signed integer (4 bytes). >i模式需要一个big-endian有符号整数(4个字节)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 字符串作为\\ x03 \\ x00 \\ x00 \\ x00到整数 - String as \x03\x00\x00\x00 to integer 无法将字符串 '\xAC\xED\x00\x05~r...' 从二进制转换为 utf8mb3 - Cannot convert string '\xAC\xED\x00\x05~r...' from binary to utf8mb3 使用redis进行Spring引导缓存,key有\\xac\\xed\\x00\\x05t\\x00\\x06 - Spring boot caching with redis,key have \xac\xed\x00\x05t\x00\x06 java.sql.SQLException:不正确的字符串值:'\xAC\xED\x00\x05sr...' - java.sql.SQLException: Incorrect string value: '\xAC\xED\x00\x05sr...' Java 使用 AsynchronousSocketChannel 将空字节 (\\x00) 作为 1 个字符发送 - Java send nullbyte (\x00) as 1 character using AsynchronousSocketChannel 在向Accumulo写入文本时尾随空(\\ x00)字符 - Trailing null (\x00) characters when writing text to Accumulo 为什么SqlExceptionHelper将布尔约束违反解释为\\ x00 - Why does SqlExceptionHelper interpret boolean constraint violation as \x00 Hibernate 数据截断:不正确的 integer 值:'\xAC\xED\x00\x05sr\x00& 尝试保存 OneToMany 关系时 - Hibernate data truncation: Incorrect integer value: '\xAC\xED\x00\x05sr\x00& when trying to save a OneToMany Relation 如何使在x:00 x:15 x:30和x:45上运行的线程在2:00做一些不同的事情 - How to make a thread that runs at x:00 x:15 x:30 and x:45 do something different at 2:00 如何在JFreeChart中以这种格式00:00:00.000将时间分配给X轴 - How to assign time in such format 00:00:00.000 to X axis in JFreeChart
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM