python - Python中的 "string"和 'string'有什么区别吗?

标签 python string quotes double-quotes

在 PHP 中,将解析用“双引号”括起来的字符串以查找要替换的变量,而用“单引号”括起来的字符串则不会。在 Python 中,这是否也适用?

最佳答案

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

关于python - Python中的 "string"和 'string'有什么区别吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/143714/

相关文章:

python - 为什么这两个平方根算法的运行方式如此不同,尽管它们应该完全相同?

python - 谷歌云运行 : Calling from outside GCP

python - 如何在 Pandas 句子列中使用自动更正

python - Keras 相当于 Caffe 的 'cpu_data()' 方法?

python - tkinter 中的按钮运动动画

java - 提取字符串的数字模式并将其放入对象中

C:删除句子中的空格;抛出异常:写访问冲突

mysql - MySQL 中何时使用单引号、双引号和反引号

c++ - 单引号在 C++ 中用于多个字符时有什么作用?

mysql - MySQL 中何时使用单引号、双引号和反引号