Escape Sequence operations allow some opertaions on the textual expressions we want to output.
You can see the most frequently used characters below. We will examine them in detail
\n ==> newline
\t ==> tab
\b ==> backline
After the newline string is written anywhere in an expression, it moves the next expression to the bottom line
\n ==> newline
For example, below, there are two sentences in print function.
Since the "\n" character is used after the first sentence, the second sentence in the output starts from a bottom line.
We can put four spaces, i.e, one tab, between this character and string expressions.
\t ==> tab
For example, below, there are two sentences in the print function.
Since the "\t" character is used after the first sentence, the second sentence starts with four spaces in the output.
We cna put the escape sequence characters one after the other and have them do more than one operaiton.
The last character we will examine is the "\b" character.
This character is short for the backline expression.
When it comes to the end of a string expression, it takes back one space from the previous value of the expression.
\b ==> backline
For example, below, there are two sentences in print function.
Since the "\b" character is used after the first sentence, the last letter of the second sentence is deleted in the output.
Becuase, "\b" deletes the previous character.
Python; Igonores any expression after the \(backslash) character.
\ ==> backslash
For example, we got an error in the first line of code. Because we used the quotation mark incorrectly.
We used the backslash mark because we wanted Python not to see the quotation mark in the next line of code, so we got an error-free output.
'Python' 카테고리의 다른 글
Methods in Strings in Python (0) | 2024.09.24 |
---|---|
Boolean Logic Expression in Python (0) | 2024.09.21 |
Python Print Function (0) | 2024.09.19 |
Arithmetic Operation in Python (0) | 2024.09.13 |
Python Type Conversion (0) | 2024.09.11 |