learn kro favicon img

 Python Escape Character Sequences (Examples)

In Python, you can use escape character sequences to include special characters in strings. An escape character is a backslash () followed by a character that represents a special meaning, such as a newline or a quote.

Here is a list of some common escape character sequences in Python:

  • \n: Newline
  • \r: Carriage return
  • \t: Tab
  • \\: Backslash
  • \': Single quote
  • \": Double quote

Here are some examples of using escape character sequences in Python:

It’s also important to note that you can use triple quotes (single or double) to define a string that spans multiple lines, without having to use escape characters for newlines.

Here is an example of using triple quotes to define a multiline string:

Leave a Comment

Your email address will not be published. Required fields are marked *