No

Peter Hansen peter at engcorp.com
Tue Feb 21 10:49:23 EST 2006


Gaz wrote:
> Check this piece of code:
> 
>     #now add an image part
>     part = writer.nextpart()
>     part.addheader('Content-Transfer-Encoding', 'base64')
>     body = part.startbody('image/jpeg')
>     base64.encode(open('c:\check.jpg', 'rb'), body)
> 
> I get the following error:
> 
> IOError: [Errno 2] No such file or directory: 'c:\\check.jpg'
>       args = (2, 'No such file or directory')
>       errno = 2
>       filename = r'c:\check.jpg'
>       strerror = 'No such file or directory'
> 
> Dont know why im getting such error, the file is there. Perhaps wrong
> filetype? Wrong read mode?

What does it show if you put "print os.listdir('c:/')" on the line 
before the open?  (You'll obviously need to import os first.)

-Peter




More information about the Python-list mailing list