擅长:python、mysql、java
<p>如果你真的想用16位存储数字,你可以使用struct。</p>
<pre><code>import struct
>>> struct.pack('h', 32767)
'\xff\x7f'
>>> struct.pack('h', -32767)
'\x01\x80'
</code></pre>
<p>可以使用<code>unpack</code>解包</p>
<pre><code>>>> a = struct.pack('h', 32767)
>>> struct.unpack('H', a)
32767
</code></pre>