相关疑难解决方法(0)

单引号与Python中的双引号

根据文档,它们几乎可以互换.是否有风格上的理由使用一个而不是另一个?

python coding-style

718
推荐指数
8
解决办法
49万
查看次数

python中单引号,双引号和三引号有什么区别?

换句话说,我怎么知道使用哪一个?

我知道当我使用琴弦时,我会这样做

    string = "This is a string"
Run Code Online (Sandbox Code Playgroud)

我何时会使用''或""""""?

python syntax quotations python-3.x

5
推荐指数
1
解决办法
1万
查看次数

python中''和""有什么区别?

可能重复:
Python中"string"和"string"之间有什么区别吗?
单引号与Python中的双引号

我注意到,我可以同时使用单引号和双引号来分隔字符串蟒蛇,和哪一个我使用分隔字符串,我可以自由地在其内部使用而无需逃避它.

例子:

ex1 = 'this works'
ex2 = "this works too"
ex3 = "it's much easier to write it's this way"
ex4 = 'but this way, it\'s possible to print out "quotes from other people"'
Run Code Online (Sandbox Code Playgroud)

在其他语言,但我见过情况下,两个地方都无所谓(在JavaScript中,双方'hi'=="hi"'hi'==="hi"返回true),而在其(在C#中,"d"是一个string同时'd'char)

现在,我想知道"引擎盖下"是否真的存在差异.python是否关心'"我使用哪个?如果真是这样,那么是以哪种方式?

python string

2
推荐指数
1
解决办法
6685
查看次数

标签 统计

python ×3

coding-style ×1

python-3.x ×1

quotations ×1

string ×1

syntax ×1