How to save a binary file?

hidura at gmail.com hidura at gmail.com
Tue Oct 5 18:50:41 EDT 2010


I did but the mistake is: Error interpreting JPEG image file (Not a JPEG  
file: starts with 0x5c 0x6e)
I think the problem is maybe in the binary code here is:

\xff\\xd8\\xff\\xe0\\x00\\x10JFIF\\x00\\x01\\x01\\x01\\x00H\\x00H\\x00\\x00\\xff\\xdb\\x00C\\x00\\x05\\x03\\x04\\x04\\x04\\x03\\x05\\x04\\x04\\x04\\x05\\x05\\x05\\x06\\x07\\x0c\\x08\\x07\\x07\\x07\\x07\\x0f\\x0b\\x0b\\t\\x0c\\x11\\x0f\\x12\\x12\\x11\\x0f\\x11\\x11\\x13\\x16\\x1c\\x17\\x13\\x14\\x1a\\x15\\x11\\x11\\x18!\\x18\\x1a\\x1d\\x1d\\x1f\\x1f\\x1f\\x13\\x17"$"\\x1e$\\x1c\\x1e\\x1f\\x1e\\xff\\xdb\\x00C\\x01\\x05\\x05\\x05\\x07\\x06\\x07\\x0e\\x08\\x08\\x0e\\x1e\\x14\\x11\\x14\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\x1e\\xff\\xc0\\x00\\x11\\x08\\x05\\xc6\\x04\\\\\\x03\\x01"\\x00\\x02\\x11\\x01\\x03\\x11\\x01\\xff\\xc4\\x00\\x1d\\x00\\x00\\x01\\x05\\x01\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x03\\x01\\x02\\x04\\x05\\x06\\x00\\x07\\x08\\t\\xff\\xc4\\x00M\\x10\\x00\\x02\\x01\\x03\\x03\\x02\\x04\\x03\\x06\\x03\\x06\\x04\\x05\\x02\\x01\\r\\x01\\x02\\x03\\x00\\x04\\x11\\x05\\x12!1A\\x06\\x13"Q2aq\\x07\\x14#BR\\x81b\\x91\\xa1\\x153r\\xb1\\xc1\\xd1$\\x82\\xe1\\xf0\\x08\\x164\\x92\\xa2C\\xc2\\xf1%5S\\xb2\\xd2\\xf2c\\xe2DE\\x176s\\xff\\xc4\\x00\\x1a\\x01\\x00\\x03\\x01\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\xff\\xc4\\x004\\x11\\x00\\x02\\x02\\x02\\x02\\x02\\x02\\x02\\x00\\x05\\x04\\x01\\x03\\x05\\x01\\x00\\x00\\x01\\x02\\x11\\x03!\\x121\\x04A"2\\x13Q\\x05Baq\\x81\\x14#3\\xf0\\x91\\xb1\\xc1\\xd1CR\\xa1\\xe1\\xf1b\\xff\\xda\\x00\\x0c\\x03\\x01\\x00\\x02\\x11\\x03\\x11\\x00?\\x00\\xf9u\\x99U\\xbd-I\\xbf\\xf8\\xab\\xbf\\xe6\\xa6\\xaf\\xc5\\xf0\\xd6F\\x9d\\x05\\x8eV\\xf8Ui\\xdb\\xe4m\\xbf\\x97m\\x0b{| 
^\\x9ao\\x9a\\xdbh\\xa4=\\x92\\xe1\\x97\\x1f\\x93\\xd5\\xfa\\xb7Q\\x1ay\\t\\xda\\xca\\xbbUv\\xfaj\\x02\\xc8\\xdbZ\\xbb\\xcd\\x93\\xd5\\xb6\\x97\\x14\\x16\\xcb\\t%\\xde\\xcb\\xbbw\\xa5\\x7fU"\\xcb\\x9d\\xbeg\\xfe\\xea\\x85\\xe6\\xb6\\xed\\xbb\\xa9\\x9b\\xd9\\x9fk| 
4qB%\\xcc\\xdbY\\x97w\\xf8[\\xf5Sw\\xb6\\xef\\xe1\\xdb\\xfahM"\\xaa\\xed\\x93s7\\xe5\\xa6o\\xdd\\xf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1\\xacj\\xf8\\xe7\\xf5QM\\xcc\\xfbH\\x12\\x9d\\xb9\\xe3\\x9c\\xd5p\\x93$\\x10:\\nT\\x9c\\x83\\xcde\\xc4\\xe9N/\\xb2\\xc8^\\xdd\\xaac\\xcd\\x1b~\\x94xoG\\x96\\x0b\\xc6\\xac\\xde\\xf5V%\\xc8\\xfa\\xd1a\\x93\\x03?\\xb5KCQ\\x83-~\\xf56\\xd5p\\xca\\xa0t\\x06\\x99%\\xdc\\xa5G\\xe2\\x0c\\xfc\\xaa30)\\xc5\\x05\\xbd%p\\xbe\\xfc\\xd6T\\xce\\xaf\\xc7\\x8d-"J\\\\L\\xa4\\xe2\\xe1\\xc6{\\x06\\xa43\\xca\\x00+!=\\x89&\\xa2\\xab\\xb3\\x11\\x83\\x8aU\\x90\\xf4#&\\x9e\\xc3\\x8c?D\\x89\\x1eBC\\x17\\xe7\\xe5B

Sorry for the last send.
> On Oct 5, 2010 6:18pm, "Jonas H." jonas at lophus.org> wrote:
> > On 10/05/2010 11:11 PM, hidura at gmail.com wrote:
> >
> >
> > Hello, how i can save a binary file, i read in the manual in the IO area
> >
> > but doesn' t show how to save it.
> >
> > Here is the code what i am using:
> >
> > s = open('/home/hidura/test.jpeg', 'wb')
> >
> > s.write(str.encode(formFields[5]))
> >
> > s.close()
> >
> >
> >
> >
> > So where's the problem? That code should work. Anyway, you want to have  
> a look at with-statements.
> >
> >
> >
> > Jonas
> >
> > --
> >
> > http://mail.python.org/mailman/listinfo/python-list
> >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101005/8f1f9b1c/attachment.html>


More information about the Python-list mailing list