擅长:python、mysql、java
<p>如果您想拥有与Python2和Python3兼容的代码,可以使用struct或array module:</p>
<pre><code># Works from Python 2.5 (maybe earlier) to Python 3.x
import struct
cdata = [...]
bindata = struct.pack("<%dB" % len(cdata), *cdata)
# And then use PIL's Image.frombytes() to construct the Image() from bindata
</code></pre>
<p>或者:</p>
^{pr2}$