Home  >  Article  >  Backend Development  >  Introducing how to use escape characters in Python in different scenarios

Introducing how to use escape characters in Python in different scenarios

Y2J
Y2JOriginal
2017-05-04 13:47:581587browse

This article mainly introduces relevant information about Python escape characters in detail. Friends who need it can refer to

Python escape characters

When the special character is used in the character, python uses backslash (\) to escape the character. As shown in the following table:

OriginalString

Sometimes we don’t want the escape characters to take effect, we just want to display the original string means, this requires using r and R to define the original string. For example:

print r'\t\r'

The actual output is

“\t\r”

##Escape characterDescription\(at end of line)Line continuation character\\Backslash symbol\'Single Quotation marks ##\"##\aRing\bBackspace\eEscape\000Empty\nNewline\vVertical tab\tHorizontal tab\rBack Car\fPage change\oyyThe character represented by the octal number yy, for example : \o12 represents a new line \xyyThe character represented by the decimal number yy, for example: \x0a represents a new line \otherOther characters are output in normal format##[Related recommendations]
Double quotation marks

1. Python free online video tutorial

2. Python basic introductory tutorial

3. Geek Academy Python video tutorial

The above is the detailed content of Introducing how to use escape characters in Python in different scenarios. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn