June 2000
Intermediate to advanced
556 pages
8h 45m
English
The \character is used in Python strings to indicate that the character or characters following the \(backslash) are to be treated in a special way. Perhaps the most common example is the string "\n" which is interpreted to mean “ASCII linefeed” also known as “newline.” There are many others including "\t" for tab and "\b" for backspace. For a full list, see section 2.4.1 of the Python Reference Manual.
Adding these special “escape codes” to regular expressions can be awkward because the \character is also considered to be a special character by Python/Perl regular expressions. For example, consider the problem of matching the two character string "\n"—that is, a backslash character immediately ...
Read now
Unlock full access