1 Antwort
+ 3
If you want to print
print('a'b')
Python will think, the string ends after the second quotation mark. Then you get an error.
By writing
print('a\'b')
You tell Python:
Please don't end the string here, just print the quotation mark.
There are many other use cases. Backslash always starts a sequence of signs with a specific purpose besides just output.