Opening File Object

Benjamin Kaplan benjamin.kaplan at case.edu
Mon Dec 21 13:05:58 EST 2009


On Mon, Dec 21, 2009 at 11:48 AM, Ray Holt <mrholtsr at sbcglobal.net> wrote:
> I use the following code:
> fileobject = open("e:\\Ray Holts Documents\\Word Documents\\1850 Warren MS
> Jenkins", 'y')
> line = fileobject.readline()
>
> I get the following error message:Traceback (most recent call last):
>   File "C:/Python26/Reading_and_Writing_Files", line 5, in <module>
>     fileobject = open("E:\\Ray Holts Documents\Word Documents\\1850 Warren
> MS Jenkins", 'r')
> IOError: [Errno 2] No such file or directory: 'E:\\Ray Holts Documents\\Word
> Documents\\1850 Warren MS Jenkins'
> I know the file exists because I opened it in MS Word. Can someone help me?
> Thanks, Ray Holt

Files usually have an extension (like .txt or .doc) but Microsoft
feels that those are too complicated so they try to hide them from
you. It's probably "1850 Warren MS Jenkins.doc" if you're opening it
with word which provides you with another problem- when you're
programming, there's no such thing as a Word document, just a
collection of 1s and 0s which will be complete nonsense if you don't
understand how Word does its formatting. Make sure it's saved as plain
text (.txt) if you're trying to open it programatically.

> --
> http://mail.python.org/mailman/listinfo/python-list
>
>



More information about the Python-list mailing list