Python has a built-in string class named "str" with many handy features (there is an older module named "string" which you should not use).
String literals can be enclosed by either triple or double or single quotes, although single quotes are more commonly used.
Backslash escapes work the usual way within both single and double quoted literals -- e.g. \n \' \". A double quoted string literal can contain single quotes without any fuss (e.g. "I didn't do it") and likewise single quoted string can contain double quotes. A string literal can span multiple lines, but there must be a backslash \ at the end of each line to escape the newline.
String literals inside triple quotes, """" or ''', can span multiple lines of text.Example:
Here in the above the 1st string enclosed in a single quote, 2nd string enclosed in a double quote and 3rd string enclosed in a triple quote. That means we observed we can print a string in three ways, like using single quote, or using double quote, or using triple quote.
In a single quoted string , if there is an another single quote then we have to put escape character(that is \) before single quote. Otherwise invalid syntax will come. For example;
Now it is right. Same case in double quote and triple quote. That means in double quote or triple quote string, if we will put another double quote or triple quote, then we have to put backslash(\) . For example;