- I know that you can create a multi-line string a few ways:
Triple Quotes
'''
This is a
multi-line
string.
'''
Concatenating
('this is '
'a string')
Escaping
'This is'\
'a string'
I also know that prefixing the string with
r
will make it a raw string, useful for filepaths.r'C:\Path\To\File'
However, I have a long filepath that both spans multiple lines and needs to be a raw string. How do I do this?
This works:
In [1]: (r'a\b'
...: '\c\d')
Out[1]: 'a\\b\\c\\d'
But for some reason, this doesn't:
In [4]: (r'on\e'
...: '\tw\o')
Out[4]: 'on\\e\tw\\o'
Why does the "t"
only have one backslash?