Today I want to talk about #Python's special escape characters
Join me in another fun thread!
๐งต๐๐
Join me in another fun thread!
๐งต๐๐
Here is a list of the most common escape characters in #Python
๐ \n - ASCII Linefeed or Newline
๐ \t - Horizontal tab
๐ \r - Carriage return
๐ \b - Backspace
๐ \f - Form feed
๐ \' - Single Quote
๐ \" - double quote
๐ \\ -Backslash
๐ \v -vertical tab
๐ \n - ASCII Linefeed or Newline
๐ \t - Horizontal tab
๐ \r - Carriage return
๐ \b - Backspace
๐ \f - Form feed
๐ \' - Single Quote
๐ \" - double quote
๐ \\ -Backslash
๐ \v -vertical tab
One of the most common escape characters in #Python is `\n` or the line feed character.
Line feed is not printable. It basically tells Python to add a newline on the end of your string.
The line feed is useful for formatting your output. You can add more than one too!
Line feed is not printable. It basically tells Python to add a newline on the end of your string.
The line feed is useful for formatting your output. You can add more than one too!
Another common escape character in #Python is `\t` or the tab character
You can use `\t` to add one or more tabs in your strings
You can use `\t` to add one or more tabs in your strings
`\r` used to be used on old versions of Mac OS as a carriage return.
`\n` is used on current Mac and Linux for new lines
`\r\n` is still the standard on Windows for new lines as far as I know
Technically, they all represent the end of a line
stackoverflow.com
`\n` is used on current Mac and Linux for new lines
`\r\n` is still the standard on Windows for new lines as far as I know
Technically, they all represent the end of a line
stackoverflow.com
I have rarely had a need for the other escape characters except in weird edge cases where I needed to escape a backslash on Windows
I hope you've enjoyed this little foray into #Python escape characters.
Follow me for more fun tips on the Python language!
Follow me for more fun tips on the Python language!
Loading suggestions...