Is there any difference between "string" and 'string' in Python?

davidmytton picture davidmytton · Sep 27, 2008 · Viewed 58.9k times · Source

In PHP, a string enclosed in "double quotes" will be parsed for variables to replace whereas a string enclosed in 'single quotes' will not. In Python, does this also apply?

Answer

Milen A. Radev picture Milen A. Radev · Sep 27, 2008

No:

2.4.1. String and Bytes literals

...In plain English: Both types of literals can be enclosed in matching single quotes (') or double quotes ("). They can also be enclosed in matching groups of three single or double quotes (these are generally referred to as triple-quoted strings). The backslash (\) character is used to escape characters that otherwise have a special meaning, such as newline, backslash itself, or the quote character...