What is the purpose of the backslash b in python, I executed print "\" foo \ bar " in the python interpreter and got this result:
>>>print "\"foo\bar" "foar
See string literals documentation:
\b ASCII Backspace (BS)
\b
It creates a backspace character. When you type this character, your terminal has stepped over the second o .
o
\b is a space character
If you want to print the string \foo\bar , do the following:
\foo\bar
>>> print r"\foo\bar" \foo\bar
This uses the raw strings available in python.
String literals may optionally have a prefix with the letter "r" or "R"; these lines are called raw lines and use different rules to interpret backslash escape sequences