Python - TypeError: expected a character buffer object
<p>I'm trying to write this data:</p>

<pre><code> playlist =  {'playlist': {u'Up in Flames': 0, u'Oceans': 0, u'No Surprises': 0}}
</code></pre>

<p>to a file like so:</p>

<pre><code> with open('playlist.txt', 'a') as f:
     f.write(playlist)
</code></pre>

<p>but it looks like writing <code>integers</code> to a file generator this error:</p>

<p><code>TypeError: expected a character buffer object</code></p>

<p>how do I correct this? Is there a better file format for my data structure?</p>