Adding a char inside path string

Tim Williams tim at tdw.net
Wed Aug 16 14:58:25 EDT 2006


On 16 Aug 2006 10:30:26 -0700, Hitesh <hitesh287 at gmail.com> wrote:
>
> Thank you all it worked!.
>
> Tim,
>
> > modRows = ['\\'+itm[0].replace(":", "$") for itm in rows]
>
> What are those two forward slashes for?

Hi Hitesh,

 \  is an escape character,  it can give unexpected results depending
on the character following it.

Try this

>>> print "c:\server\test"

then try

>>> print "c:\\server\\test"

If you need \ in a string, you should use a pair of them for safety, see

http://docs.python.org/ref/strings.html

and http://pyfaq.infogami.com/windows-index  (the comments section)

HTH :)



More information about the Python-list mailing list