I got a little confused about Python raw string. I know that if we use raw string, then it will treat \'\\\'
as a normal backslash (ex. r\'\\n\'
wo
The simplest answer is to simply not use a raw string. You can escape backslashes by using \\
.
If you have huge numbers of backslashes in some segments, then you could concatenate raw strings and normal strings as needed:
r"some string \ with \ backslashes" "\n"
(Python automatically concatenates string literals with only whitespace between them.)
Remember if you are working with paths on Windows, the easiest option is to just use forward slashes - it will still work fine.