Binary To File

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Apr 12 19:32:43 EDT 2007


En Thu, 12 Apr 2007 20:16:28 -0300, Daniel Nogradi <nogradi at gmail.com>  
escribió:

>> Is there an easy way to take binary data and build it into a file?
>
> myblob = ......... # let's say you got it from your database somehow
> myjpeg = open( 'image.jpg', 'w' )
> myjpeg.write( myblob )
> myjpeg.close( )

For some platforms using open(..., "wb") is important, and won't hurt on  
the others, so it's the preferred way.

-- 
Gabriel Genellina




More information about the Python-list mailing list