Meaning Of 3 Quotes In Python
Python s triple quotes comes to the rescue by allowing strings to span multiple lines including verbatim newlines tabs and any other special characters.
Meaning of 3 quotes in python. For single line string assignment there s no significance. Triple quotes for string creation. However if either single or double quote is a part of the string itself then the string must be placed in double or single quotes respectively.
Defining strings in python all of the following are equivalent my string hello print my string my string hello print my string my string. Python programming provides us a very simple way to deal with multi line strings. Strings can be created by enclosing characters inside a single quote or double quotes.
Triple quote for multi line strings in python programming. Enclose strings containing both single and double quotes such that no escaping is needed. Either single or double quotes are fine.
Adding the required characters within triple quotes can convert those characters into python strings the below codes shows the use of triple quotes for creating strings. These quotation marks could either be double quotes or single quotes. To print a multi line string in python we use triple quotes.
By triple quotes i mean set of quotation marks enclosed within each other. Code d hello user works d hello user works but no significance of d. We can also uses in multiples lines but triple quotes look much better.
Even triple quotes can be used in python but generally used to represent multiline strings and docstrings. Use single quotes as enclosing quotes to eliminate the need of escaping double quotes in a string and vice versa. The syntax for triple quotes consists of three consecutive single or double quotes.