[Tutor] Write new line(enter) in txt
Susana Iraiis Delgado Rodriguez
susana.delgado_s at utzmg.edu.mx
Mon Mar 28 17:12:05 CEST 2011
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')
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()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110328/f289da34/attachment.html>
More information about the Tutor
mailing list