换句话说,我怎么知道使用哪一个?
我知道当我使用琴弦时,我会这样做
string = "This is a string"
Run Code Online (Sandbox Code Playgroud)
我何时会使用''或""""""?
我注意到,我可以同时使用单引号和双引号来分隔字符串蟒蛇,和哪一个我不使用分隔字符串,我可以自由地在其内部使用而无需逃避它.
例子:
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是否关心'和"我使用哪个?如果真是这样,那么是以哪种方式?