Unknown python expression filename=r'/path/to/file'
Solution 1:
The r'..'
string modifier causes the '..'
string to be interpreted literally. That means, r'My\Path\Without\Escaping'
will evaluate to 'My\Path\Without\Escaping'
- without causing the backslash to escape characters. The prior is equivalent to 'My\\Path\\Without\\Escaping'
string, but without the raw modifier.
Note: The string cannot end with an odd number of backslashes, i.e r'Bad\String\Example\'
is not a correct string.
Solution 2:
It's called raw string literal.
According to Python String literals documentation
:
The backslash (\) character is used to escape characters that otherwise have a special meaning, such as newline, backslash itself, or the quote character. String literals may optionally be prefixed with a letter 'r' or 'R'; such strings are called raw strings and use different rules for interpreting backslash escape sequences.
...
Unless an 'r' or 'R' prefix is present, escape sequences in strings are interpreted according to rules similar to those used by Standard C