[Tutor] Open file error

bob bgailer at alum.rpi.edu
Tue Jan 17 19:20:59 CET 2006


At 09:23 AM 1/17/2006, Paul Kraus wrote:
>On Tuesday 17 January 2006 12:11 pm, andy senoaji wrote:
> > I am starting to pull my hair here. There were some postings in the past,
> > similar to my problem, but the response was not clear enough. Sorry if you
> > thingk I am reposting this.
> >
> > I am trying to run (on an XP box) a simple open file using this:
> > f = open(r'C:\Test.txt', 'r')Newbie here but shouldn't it be.
>
>Newbie Here
>
>f = open( r'C:\\Test.txt','r')
>
>I think you are escaping the T with \T.

More specifically you show us  f = open(r'C:\Test.txt', 'r')
but the traceback shows the statement to be f = open('Test.txt', 'r')

Something is being lost between these 2 items.

When I try f = open( r'C:\Test.txt','r')
The traceback reports IOError: [Errno 2] No such file or directory: 
'c:\\test.txt'
Note the \\
Your traceback reports IOError: [Errno 2] No such file or directory: 
'c:\test.txt' confirming the Paul's diagnosis.
Are you using IDLE? Are you running a script vs trying a command interactively? 



More information about the Tutor mailing list