python backslash as string code example
Example 1: r string python
>>> print("This is a line feed : \n and it's usefull!")
This is a line feed :
and it's usefull!
>>> print(r"This is not a line feed /n :(")
This is not a line feed /n :(
my_path = "C:\Users\Me\Desktop\MyFile.txt"
my_path = r"C:\Users\Me\Desktop\MyFile.txt"
Example 2: python tab character
Escape Sequence Meaning
\t Tab
\\ Inserts a back slash (\)
\' Inserts a single quote (')
\" Inserts a double quote (")
\n Inserts a ASCII Linefeed (a new line)
Example 3: python backslash in string
print("\\")
\
Example 4: python escape characters
\' Single Quote
\\ Backslash
newline = '\n'