more on unescaping escapes
Tim Wintle
tim.wintle at teamrubber.com
Mon Feb 23 19:13:06 EST 2009
On Mon, 2009-02-23 at 17:00 -0700, bvdp wrote:
> Let's see if this makes sense:
>
> >>> a='c:\\Program Files\\test'
> >>> a.decode('string-escape')
> 'c:\\Program Files\test'
Hint: try running
>>> print a
and see what's written - I think that the interpreter adds extra "\"
characters to escape things and make things more easy to read.
i.e.
>>> a = "c:\\test\\t"
>>> a
'c:\\test\\t'
>>> print a
c:\test\t
>>>
so when it displays strings in the interpreter it includes escape
characters, when it is printed though the output is straight to stdout
and isn't escaped.
Hope that helps,
Tim Wintle
More information about the Python-list
mailing list