Python error: TypeError: POST data should be bytes
<p>In my below code I am getting an error "raise TypeError("POST data should be bytes"
TypeError: POST data should be bytes or an iterable of bytes. It cannot be str."</p>

<p>What am I doing wrong  ? I am using python 3.2.2</p>

<p>Below is the code:</p>

<pre><code>msg = "Test post"
password_manager = urllib.request.HTTPPasswordMgr()
password_manager.add_password("Twitter API",
"http://twitter.com/statuses", "sampleusername", "password")
http_handler = urllib.request.HTTPBasicAuthHandler(password_manager)
page_opener = urllib.request.build_opener(http_handler)
urllib.request.install_opener(page_opener)
params = urllib.parse.urlencode( {'status':msg} )
resp = urllib.request.urlopen("http://twitter.com/statuses/update.json", params)
resp.read()
</code></pre>
