17 python
在Python中使用双引号与单引号之间有什么区别吗?
"A string with double quotes"
'A string with single quotes'
Run Code Online (Sandbox Code Playgroud)
它们是一样的吗?python如何解释这些字符串有什么不同吗?
And*_*eto 23
简短回答:除了风格上几乎没有区别.
Short blurb:如果您不想转义字符串中的引号字符,请使用其他类型.例如:
string1 = "He turned to me and said, \"Hello there\""
Run Code Online (Sandbox Code Playgroud)
会比说的更难看
string2 = 'He turned to me and said, "Hello there"'
Run Code Online (Sandbox Code Playgroud)
这同样适用于单引号/撇号.
| 归档时间: |
|
| 查看次数: |
18942 次 |
| 最近记录: |