[Tutor] Trouble with encoding/decoding a file
tony.pelletier at gmail.com
Mon Feb 6 19:40:29 CET 2012
On Mon, Feb 6, 2012 at 1:13 PM, Alan Gauld <alan.gauld at btinternet.com>wrote:
> On 06/02/12 15:11, Tony Pelletier wrote:
>> I've been tasked with getting the encoded value using a SOAP call and
>> then writing the file out. I first used the interpreter to do so like
>> import base64
>> encoded = 'super long encoded string'
>> data = base64.b64decode(encoded)
>> outfile = open('test.xls', 'w')
> Have you tried opening as a binary file?
>> Excel .xls uses binary data...
Unbelievable. In the snippet you quoted above, it didn't matter. That one
always worked, but changing it in the code I wrote, it totally fixed it. :)
> Alan G
> Author of the Learn to Program web site
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor