擅长:python、mysql、java
<p>你只需要解码这个二进制文件,你就会得到答案</p>
<pre><code>x = b'\x001\x002\x001\x000\x005\x005\x000\x004\x000\x000\x00'
str1 = x.decode('utf-8')
print(" ".join([i for i in str1 if ord(i) != 0]))
</code></pre>
<p>第二种解决方案:</p>
<pre><code>x = '1 2 1 0 5 5 0 4 0 0'
str_utf32 = x.encode('utf16')
print("Encoding :",str_utf32)
print("Decoding :",str_utf32.decode('utf16'))
</code></pre>
<p>输出</p>
<pre><code>Encoding : b'\xff\xfe1\x00 \x002\x00 \x001\x00 \x000\x00 \x005\x00 \x005\x00 \x000\x00 \x004\x00 \x000\x00 \x000\x00'
Decoding : 1 2 1 0 5 5 0 4 0 0
</code></pre>