[Tutor] Open file error

Alan Gauld alan.gauld at freenet.co.uk
Tue Jan 17 19:08:15 CET 2006


>> 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.

The r in front of the string should prevent that problem. 
If the r wasn't there you would be right and he would need
to escape the \ ...or use a forward slash!

Alan G.


More information about the Tutor mailing list