On Mon, Mar 28, 2011 at 11:28 AM, Susana Iraiis Delgado Rodriguez < susana.delgad...@utzmg.edu.mx> wrote:
> Ok Flyyn! > Thank you for answered my question. I think I didn't explain what I need. > The printing statement is used to print a message to the Windows console, > then the other line written in the else statement is: > > log.write('No existe el archivo ' +shx+"\n") > This is the part I'm struggling with, I don't know how to add the "new > line" to the txt > > 2011/3/28 Flynn, Stephen (L & P - IT) <steve.fl...@capita.co.uk> > >> You don't "print" a newline when you print each line of the file >> contents... >> >> >> >> print 'El archivo ' +shx +' existe' >> >> >> >> >> >> You need to add a newline: >> >> print 'El archivo ' +shx +' existe' + '\n' >> >> >> >> >> ________________________________________ >> From: tutor-bounces+steve.flynn=capita.co...@python.org [mailto: >> tutor-bounces+steve.flynn=capita.co...@python.org] On Behalf Of Susana >> Iraiis Delgado Rodriguez >> Sent: Monday, March 28, 2011 4:12 PM >> To: tutor@python.org >> Subject: [Tutor] Write new line(enter) in txt >> >> >> Hello list!! >> >> This is a very simple question!! I want to write some lines in a txt file, >> but my output looks like this: >> No existe el archivo C:\índice.dbfNo existe el archivo C:\índice_dwg.dbfNo >> existe el archivo C:\índice_raster.dbf >> I need it to look like this: >> No existe el archivo C:\índice.dbf >> No existe el archivo C:\índice_dwg.dbf >> No existe el archivo C:\índice_raster.dbf >> >> The code I wrote is: >> log = open ('errors.txt','wb') >> > Change the above line to log = open('errors.txt, 'w') You are opening your log file in binary mode, so your operating system doesn't convert your '\n' to what it needs for new line > shp = 'Error al abrir el archivo' +filepath >> log.write(shp+"\n") >> n = os.path.splitext(filepath) >> p = n[0]+'.prj' >> shx = n[0]+'.shx' >> dbf = n[0]+'.dbf' >> if os.path.exists(shx): >> print 'El archivo ' +shx +' existe' >> else: >> log.write('No existe el archivo ' +shx+"\n") >> if os.path.exists(dbf): >> print 'El archivo ' +dbf +' existe' >> else: >> log.write('No existe el archivo ' +dbf+"\n") >> log.close() >> >> >> This email has been scanned for all viruses by the MessageLabs SkyScan >> service. >> >> This email and any attachment to it are confidential. Unless you are the >> intended recipient, you may not use, copy or disclose either the message or >> any information contained in the message. If you are not the intended >> recipient, you should delete this email and notify the sender immediately. >> >> Any views or opinions expressed in this email are those of the sender >> only, unless otherwise stated. All copyright in any Capita material in this >> email is reserved. >> >> All emails, incoming and outgoing, may be recorded by Capita and monitored >> for legitimate business purposes. >> >> Capita exclude all liability for any loss or damage arising or resulting >> from the receipt, use or transmission of this email to the fullest extent >> permitted by law. >> > > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > -- Joel Goldstick
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor