擅长:python、mysql、java
<p>用Python发送二进制数据的主要方法是使用<a href="https://docs.python.org/2/library/struct.html" rel="noreferrer">struct</a>模块。</p>
<p>例如,打包3个4字节无符号整数如下</p>
<pre><code>In [3]: struct.pack("III", 3, 4, 5)
Out[3]: '\x03\x00\x00\x00\x04\x00\x00\x00\x05\x00\x00\x00'
</code></pre>
<p>注意,要保持结尾正确,请使用“<;”、“>;”等。</p>