simple string question
jwither
jwither at sxder4kmju.com
Mon Sep 7 23:56:51 EDT 2009
"ryles" <rylesny at gmail.com> wrote in message
news:b96be200-9762-4f92-bd0d-9be076bcd786 at y20g2000vbk.googlegroups.com...
>
>> There's probably a more general method covering all the escape
>> sequences, but for just \n:
>>
>> your_string = your_string.replace("\\n", "\n")
>
> py> s = "hello\\r\\n"
> py> s
> 'hello\\r\\n'
> py> s.decode("string_escape")
> 'hello\r\n'
> py>
>
Even though that's what I asked for, I'll stick with the "replace" for now.
But it's cool though: I can embed generic uni-code as well as simple escape
sequences!
Thanks,
James Withers.
More information about the Python-list
mailing list