I use this text text\r2
. And I want to print this in debug and get result:
text\r2
but I get this:
text
2
I use this text text\r2
. And I want to print this in debug and get result:
text\r2
but I get this:
text
2
Try to escape the backslash with another backslash: text\\r2
.
The \r
will otherwise be interpreted as a line break.
\r
in a String literal is a special character and represents a carriage return
See Special Characters in String Literals
String literals can include the following special characters: * The escaped special characters \0 (null character), \\ (backslash), \t (horizontal tab), \n (line feed), \r (carriage return), \" (double quotation mark) and \' (single quotation mark) * An arbitrary Unicode scalar, written as \u{n}, where n is a 1–8 digit hexadecimal number with a value equal to a valid Unicode code point (Unicode is discussed in Unicode below)
If you want to use in a String Literal a backslash you have to escape it using \\
.
So you'll have to write
print("text\\r2")
to get text\r2