Binary To File
Grant Edwards
grante at visi.com
Thu Apr 12 19:26:17 EDT 2007
On 2007-04-12, Daniel Nogradi <nogradi at gmail.com> wrote:
>> Is there an easy way to take binary data and build it into a file? Generally
>> this will be BLOB data drawn from a database, the data will be for jpg
>> images, I want to take the blob data and build it into a physical .jpg file.
>>
>>
>>
>> Is there a simple function for doing this in python? Like binary2file() or
>> something along those lines?
>
> myblob = ......... # let's say you got it from your database somehow
> myjpeg = open( 'image.jpg', 'w' )
myjpeg = open( 'image.jpg', 'wb' )
> myjpeg.write( myblob )
> myjpeg.close( )
>
>
> Daniel
--
Grant Edwards grante Yow! NOW, I'm supposed
at to SCRAMBLE two, and HOLD
visi.com th' MAYO!!
More information about the Python-list
mailing list