<br><br><div class="gmail_quote">On Mon, Mar 28, 2011 at 11:12 AM, Susana Iraiis Delgado Rodriguez <span dir="ltr">&lt;<a href="mailto:susana.delgado_s@utzmg.edu.mx">susana.delgado_s@utzmg.edu.mx</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello list!!<br><br>This is a very simple question!! I want to write some lines in a txt file, but my output looks like this:<br>No existe el archivo C:\índice.dbfNo existe el archivo C:\índice_dwg.dbfNo existe el archivo C:\índice_raster.dbf<br>


I need it to look like this:<br>No existe el archivo C:\índice.dbf<br>No existe el archivo C:\índice_dwg.dbf<br>No existe el archivo C:\índice_raster.dbf<br><br>The code I wrote is:<br>log = open (&#39;errors.txt&#39;,&#39;wb&#39;)<br>


shp = &#39;Error al abrir el archivo&#39; +filepath<br>log.write(shp+&quot;\n&quot;)<br>n = os.path.splitext(filepath)<br>p = n[0]+&#39;.prj&#39;<br>shx = n[0]+&#39;.shx&#39;<br>dbf = n[0]+&#39;.dbf&#39;<br>if os.path.exists(shx):<br>


                        print &#39;El archivo &#39; +shx +&#39; existe&#39;<br>                else:<br>                        log.write(&#39;No existe el archivo &#39; +shx+&quot;\n&quot;)<br>                if os.path.exists(dbf):<br>


                        print &#39;El archivo &#39; +dbf +&#39; existe&#39;<br>                else:<br>                        log.write(&#39;No existe el archivo &#39; +dbf+&quot;\n&quot;)<br>log.close()<br><br>
<br></blockquote><div>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.<br>
<br><br><a href="http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files">http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files</a><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Joel Goldstick<br><br>