+ 1
What is an escape character?
There is a question in python quiz saying which one of the followimg is an escape charater.Please tell me what exactly an escape character is.
6 Respuestas
+ 11
Escape characters are used for escape sequence from the string for it to be printed and also for special characters. We use backslash (\) to escape characters.
Common examples are \n and \t which indicates new line and tab, respectively.
It is also used for regular expressions:
\w ---> word
\d ---> digit
etc.
See this code for quick examples.
https://code.sololearn.com/cRiJax343R7Y/?ref=app
+ 8
Often if you want to write '\' itself, you have to escape it with another '\' and write "\\"
+ 6
An Escape character is a character that starts an escape sequence in a string, that means a sequence that is not printed as it is written.
For example:
"\n" newline
"\t" tab
So '\' is an escape character
+ 4
It's a wand that gives the following character magic powers
"n" on is own is just "n"
\.-*-._.- "n" abra kadabra! ...
boom!
\n now n has the power to create a new line. 😁
but sometimes it can remove its magic powers
0
Regarding "\\", in stings where you don't want escaping sequences at all, you can use raw-strings (r"...")
Useful in file paths and regex for example
0
Thank you guys
I know this was a small question yet you told me the answer😸