Language Syntax

Raw string literal — Python syntax

A raw string preserves backslashes in most escape-looking sequences. Quotes still participate in lexical parsing; a raw literal cannot end with an odd number of backslashes. Useful for regular expressions but not a universal escaping mechanism.

Formal Syntax & Structure

python syntaxpython
r"text\n"

Return Value

str

Value obtained by evaluating this expression; see description for context and constraints.

Working Example

Example Snippetpython
text=r'\n'print((text,len(text)))
Python Reference