【发布时间】:2019-08-11 10:56:49
【问题描述】:
参考以下问题 -
1) different run results between python3 and python2 for the same code
2) “is” operator behaves unexpectedly with integers
3)Consecutive 'is' operator in Python [duplicate]
5)What does 'is' operator do in Python?
6) Strange python 'is' operator in arithmetic [duplicate]
7) Why does the “is” keyword have a different behavior when there is a dot in the string?
不重复问题的解释 - 在我的问题中,我没有包含任何符号、数值。我包括简单的字符串。在上面提到的第 7 个问题中,我已经知道给出不同输出的原因,并且我已经阅读过。
在这里,我的问题有所不同。
我的问题描述 -
我正在练习使用 3.6.8 版本的 Python 代码并使用 PyCharm 编辑器。
print('a' * 18 is 'aaaaaaaaaaaaaaaaaa')
print('a' * 19 is 'aaaaaaaaaaaaaaaaaaa')
print('a' * 20 is 'aaaaaaaaaaaaaaaaaaaa')
print('a' * 21 is 'aaaaaaaaaaaaaaaaaaaaa')
print('a' * 22 is 'aaaaaaaaaaaaaaaaaaaaaa')
输出 =
True
True
True
False
False
为什么'a' * 21 is 'aaaaaaaaaaaaaaaaaaaaa' 及以后的字符串不会评估为 True?
任何帮助将不胜感激
【问题讨论】:
标签: python-3.x string pycharm operators