Re: Raw strings to normal strings conversion?
- From: Nagarajan <naga86@xxxxxxxxx>
- Date: Thu, 23 Aug 2007 10:20:21 -0000
On Aug 23, 2:42 pm, Marc 'BlackJack' Rintsch <bj_...@xxxxxxx> wrote:
On Thu, 23 Aug 2007 09:21:40 +0000, Nagarajan wrote:
On Aug 23, 1:21 pm, James Stroud <jstr...@xxxxxxxxxxxx> wrote:
Nagarajan wrote:
Is there a way by which I could obtain normal string form of a raw
string.
XML CDATA is returned as raw string. But I need the string to actually
escape special chars.
Any idea?
This doesn't seem clear. Perhaps an example of what you get and what you
want it converted to.
Here is an example:
a\nbrawstr = r'a\nb'
print rawstr
Now I need this newstr to actually interpret '\n', in other words, to
behave like a normal string.
So you get a string with Newlines as two character sequence \n. You don't
get "raw" strings. That is a concept in Python source code. When the
program is running there is no such distinction between "raw" and "normal"
strings. Here's a solution:
In [87]: print r'a\nb'
a\nb
In [88]: print r'a\nb'.decode('string-escape')
a
b
Ciao,
Marc 'BlackJack' Rintsch
Thanks a lot.
.
- References:
- Raw strings to normal strings conversion?
- From: Nagarajan
- Re: Raw strings to normal strings conversion?
- From: James Stroud
- Re: Raw strings to normal strings conversion?
- From: Nagarajan
- Re: Raw strings to normal strings conversion?
- From: Marc 'BlackJack' Rintsch
- Raw strings to normal strings conversion?
- Prev by Date: Socket recv(1) seems to block instead of returning end of file.
- Next by Date: Re: Impersonate another user temporarily (Unix and Windows)
- Previous by thread: Re: Raw strings to normal strings conversion?
- Next by thread: Are there precompiled python for sgi ?
- Index(es):
Relevant Pages
|