title: Convert file stream to base64 python
body: <p>I have read the file stream of a zip file by the following code:  </p>
  
  <pre><code>file = open(source_url, "rb")  
  data = file.read()  
  file.close()  
  byte_arr = base64.b64encode(data)
  </code></pre>
  
  <p>Now I am trying to call a webservice which accepts base64Binary format of data (byte array written in java). If I send byte_arr to the web-service I get client error:<br>
  Fault env:Client: Caught exception while handling request: unexpected element type: expected={http://www.w3.org/2001/XMLSchema}base64Binary, actual={http://www.w3.org/2001/XMLSchema}string</p>
  
  <p>Please suggest why is base64 module not working for me.<br>
  type(byte_arr) is still string.<br>
  With thanks,<br>
  Sandhya</p>