Help with ASCII (UNIX<->DOS)
jeff at ccvcorp.com
Thu Sep 27 02:33:47 CEST 2001
> I've made a simple Python prog that connects to an IMAP server ,
> checks the accounts for new mails, & if it finds so, it retrieves
> them, & saves them 2 a file...
> The problem is that with these lines of code,
> typ, data = M.fetch(num, '(RFC822)')
> WriteEmail('%s\n' % (data))
> def WriteEmail(Uname,EData):
I don't know about any other problems, but it looks like you're defining
WriteEmail to take two arguments, but you're only calling it with one --
'%s\n' % data (the inner parens are unnecessary) resolves into a
> I read about UNICODE & conversions... but I feel lost...
> I need 2 create a file with standard DOS (ASCII) with 0D 0A (CRLF).
I don't know that this has anything to do with unicode. It's not terribly
clear to me just what your problem is, but at a guess... are you trying to
create a file in under Unix, that uses DOS-style line-endings (CRLF vs CR)
If that is the case, you could try doing something like
CRLF = chr(10) + chr(13)
and then concatenate CRLF into your strings wherever you'd otherwise use
\n -- '%s%s' % (data, CRLF) for example. You'll also need to write
to your file in binary mode, of course.
If I'm mistaken about what you're trying to do, please feel free to
More information about the Python-list