Escape using triple quote
Triple quotes (or docstrings as they are called in official python documentation) can be used to represent multiple strings containing quotes.
Python3
print ( ''' Hello I don't dislike python He said, "he likes python" ''' ) |
Output:
Hello I don't dislike python He said, "he likes python"
How to Escape Quotes From String in Python
The single or double quotation is a unique character that can be used in a Python program to represent a string by encapsulating it in matching quotes. When the quotes are used inside a string contained in similar quotes it confuses the compiler and as a result, an error is thrown.
This article will demonstrate how to escape quotes from a string in Python.