On Mon, Mar 28, 2011 at 11:12 AM, Susana Iraiis Delgado Rodriguez <
susana.delgad...@utzmg.edu.mx> wrote:

> 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()
>
>
> Windows systems I believe need cr/lf for end of line character.  You should
first try opening your file in text mode, not binary.  Then your \n will be
translated into whatever end of line sequence your operating system
requires.


http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files


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

Reply via email to