Why does Python not return first line?
garrickp at gmail.com
Mon Mar 16 23:20:18 CET 2009
On Mar 15, 6:25 pm, Gilles Ganault <nos... at nospam.com> wrote:
> address = re_address.search(response)
> if address:
> address = address.group(1).strip()
> for item in ["\t","\r"," <br />"]:
> address = address.replace(item,"")
As you found, your script works just fine, it's just that during
terminal output the \r performs a carriage return and wipes out
everything prior to it.
FWIW, I've rarely seen a \r by itself, even in Windows (where it's
usually \r\n). Unix generally just outputs the \n, so my guess is that
some other process which created the output removed newline
characters, but didn't account for the carriage return characters
Wiping out the \r characters as you did will solve your display
issues, though any other code should read right past them.
More information about the Python-list