[Python] Eliminare carattere fine riga

Marco Beri marcoberi a gmail.com
Mar 24 Lug 2012 14:14:21 CEST


2012/7/24 Daniele Varrazzo <piro a develer.com>

> In windows forse "rstrip('\r\n')" è anche meglio, ma non sono sicuro sia
> necessario (forse py converte CRLF -> LF? Non mi ricordo).
>

Secondo me non converte.

marcob a pc-beruntu:~$ od -c x
0000000  \r  \n
0000002
marcob a pc-beruntu:~/tmp$ python
Python 2.7.2+ (default, Oct  4 2011, 20:03:08)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> file("x", "r").read()
'\r\n'
>>> file("x", "rb").read()
'\r\n'

Ciao.
Marco.
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.python.it/pipermail/python/attachments/20120724/4ebad85b/attachment.html>


Maggiori informazioni sulla lista Python