def b64open(url, postdata):
    req = Request(url, b2a_base64(postdata), headers={
        'Content-Transfer-Encoding': 'base64'})
return urlopen(req)
conn = b64open('http://www.whatever.com/script.cgi',
    'Libert\xe9 \xc9galit\xe9 Fraternit\xe9')
Send file using POST from a Python script