[Tutor] Converting binary file date into a file?
Eric Brunson
brunson at brunson.com
Fri Jan 18 22:42:10 CET 2008
Ole Jensen wrote:
> Hi
>
> I made a small python program at home and tried to send by email
> attachments to my studymates.
> The attachment however shows up as a strange text
>
> the first lines look like this:
>
> M1F]R<_AG(#(@+2 R(&=E;F5R871O<F5R("T at 1$<R#0H@"5!I"0E08 at D)4"!O
> M;&EE<'5M<&4)4"!V86YD<'5M<&4)4"!F<FEK=&EO;@EB97)E9VYE="!08 at T*
> M5&EM92 P( DS-C4Q-3 at N-30T-#0T( DS-C(S-C N," ),3(R,BXR,C(R,C(R
> M,B ),30V-"XP.#@X ...
> <http://groups.google.com/groups/unlock?msg=c42d7058ff6b0c28&hl=en&_done=/group/gruppe-b1/browse_thread/thread/23a5c2bfae647d8b%3Fhl%3Den>@X.2
> ),3$R+C(S,S,S,S,S,R ),S0Y,3,T+C$W,S at U
> M,PT*5&EM92 Q( DS-3 at P.#4N-CDT-#0T( DS-34S-# N," ),3(R,BXR,C(R
>
> I was thinking that it might be the binary representation of my .py
> files? (the files were not compresses, just basic .py-files)
> If so is there anyways its possible to convert it back into an
> ordinary text file? through either Python og Windows?
Your email application attached the files using a standard called MIME
(Multipurpose Internet Mail Extensions, see:
http://www.faqs.org/rfcs/rfc2045.html
Part of the standards involves the choice of using a base64 encoding to
ensure the attachment is 7-bit clean to properly transfer over SMTP,
that's what you're seeing is the encoded attachment.
Several things may have happened. 1) the program you used to send the
mail didn't perform the MIME attaching correctly and didn't include the
proper information for the receiver to decode, 2) something corrupted
the email in transit or 3) the email client reading the email doesn't
know how to handle MIME.
If the problem is not 2 then you could open the email with a different
mail application or you could save the raw email to a file and try to
use python or other tools to extract the content.
Check out http://docs.python.org/lib/module-email.html for details on
extracting MIME from email messages or simply look at
http://docs.python.org/lib/module-base64.html for info on decoding the
attachment after you've manually extracted the encoded text from the file.
Hope that's at least a little bit of help,
e.
>
> I ain'tt gonna be back to my own PC for the rest of the weekend so
> some of the study work requires me to decode the attachments.
>
> All help highly appriciated
> Best regards
>
> Ole Jensen
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list