In python console:
>>> x="\t"
>>> x
'\t'
>>> print(x)
>>>
How can make print(x) output \t
?
CodePudding user response:
\t
is a tabulator sign but if you want to print value "\t"
you have to escape it two times:
x = "\\t hello"
y = "\t hello"
print(x)
print(y)
Output
"\t hello"
" hello"
CodePudding user response:
You can use a raw string to avoid escaping the backslash like in Avad’s answer:
x = r"\t"
print(x)