Python escape characters are described in detail


Python escape character

python USES a backslash (\) to escape characters when special characters need to be used in characters. The following table:

Original string

Sometimes we don’t want the escape character to work, we just want to show the original meaning of the string, so we define the original string using r and R. Such as:

print r'\t\r'

The actual output is

 " \t\r "
转义字符描述
\(在行尾时)续行符
\\反斜杠符号
\‘单引号
\“双引号
\a响铃
\b退格(Backspace)
\e转义
\000
\n换行
\v纵向制表符
\t横向制表符
\r回车
\f换页
\oyy8进制数yy代表的字符,例如:\o12代表换行
\xyy10进制数yy代表的字符,例如:\x0a代表换行
\other其它的字符以普通格式输出

Thank you for reading, I hope to help you, thank you for your support of this site!