How to write bytes to file from Python shell? : <p>I have tried this
key</p>

<pre><code>b"\xa9Z\xfe\x16*L\xfaJ\xab\x87\xc3\xdf$:f\xb3U^\xf4Nf\xe8\xc2\x1cZ\xc1\xd8\xdc\xe4h\x98\xac\xa3b\x98\xbc\x9e\xb5\xa8\x8d\xf7n\x1b\xa6\xbfMe\xa4\xd8\xc0\xd9'\x10\x86L?\xd3\xd4\xbd\xc2H\xaa\xe7\x07"
</code></pre>

<p>Open file in wb mode</p>

<pre><code>&gt;&gt;&gt; f = open('privkey.bin', 'wb' )
&gt;&gt;&gt; f.write(key)
64
</code></pre>

<p>Any way the file is empty.
Why?</p>
