The string '\n' is used to insert a line break and '\t' inserts a horizontal tabulator (TAB) into the string to align several lines:
print('Temperature\t20\tC\nPressure\t5\tPa')
These strings are examples of escape sequences. Escape sequences always start with a backslash, \. A multiline string automatically includes escape sequences:
a="""
A multi-line
example"""
a # returns '\nA multi-line \nexample'
A special escape sequence is "\\", which represents the backslash symbol in text:
latexfontsize="\\tiny"
print(latexfontsize) # prints \tiny
The same can be achieved by using a raw string instead:
latexfs=r"\tiny" # returns "\tiny"
latexfontsize == latexfs # returns True
Note that in raw strings, the backslash remains in the string and is used to escape some special characters:
print(r"\"") # returns \"
print(r"\\") # returns \
print(r"\") # returns an error (why?)
A raw string is a convenient tool to construct strings in a readable manner. The result is the same:
r"\"" == '\\"'
r"She: \"I am my dad's girl\"" == 'She: \\"I am my dad\'s girl\\"'