Q:

Python - "\" character

I'm newbie in Python. I'm trying to insert in a string a "\" character, but if i declare it like this, it takes \" as a " character.
I also tried to declare, e.g. fname='\\'
but it does not work.
What I mean to do is to add to a path e:\\Others\Contacts the string \<filename>.
May anyone help me?

A:

backslash = '\\'

You can also use raw string literals. Note that there's no way to have a backslash at the end of a raw string literal though.
path = r'e:\Others\Contacts'

However, instead of fiddling with backslashes, you should use os.path.join to concatenate paths:
import os.path
p = os.path.join('e:', 'Others', 'Contacts', filename)

