[Tutor] Python file escaping issue?

Sithembewena Lloyd Dube zebra05 at gmail.com
Sun Feb 21 19:22:10 CET 2010


Hi all,

I'm trying to read a file (Python 2.5.2, Windows XP) as follows:

assignment_file = open('C:\Documents and Settings\coderoid\My
Documents\Downloads\code_sample.txt', 'r+').readlines()
new_file = open(new_file.txt, 'w+')
for line in assignment_file:
    new_file.write(line)

new_file.close()
assignment_file.close()

When the code runs, the file path has the slashes converted to double
slashes. When  try to escape them, i just seemto add more slashes. What am i
missing?


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100221/4f3b7129/attachment.html>


More information about the Tutor mailing list