“字符串”和“字符串”之间有什么区别吗?和Python中的“字符串”?

“字符串”和“字符串”之间有什么区别吗?和Python中的“字符串”?

问题描述:

在PHP中,将解析包含在双引号中的字符串以替换变量,而不会解析包含在单引号中的字符串。在Python中,这是否也适用?

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?


2.4.1。字符串和字节文字量



...简而言之:两种类型的文字量都可以用匹配的单引号引起来(')或双引号( )。也可以将它们括在三个单引号或双引号的匹配组中(通常称为三引号字符串)。反斜杠( \ )字符用于转义具有特殊含义的字符,例如换行符,反斜杠本身或引号字符...

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...