带有感叹号的字符串是否可以防止Python进行字符串内插?

时间:2018-09-30 07:09:34

标签: python string

请考虑以下两种情况:

>>> a = "python is cool!"
>>> b = "python is cool!"
>>> a is b
False

>>> a = "python"
>>> b = "python"
>>> a is b
True   # a and b refer to the same object!

我想知道为什么在第二种情况而不是第一种情况下发生字符串实习。是由于感叹号还是一般长度?谢谢!

0 个答案:

没有答案