-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Section: Strain your brain! --> Strings can be tricky sometimes *中有条示例似乎已经不适用了 #13
Comments
你好,我测试了3.7.0和3.7.1,确实从3.7开始这条的结果就变了。 多谢你的细心测试,我会在文中注明这点并将你加入到贡献者名单里,欢迎继续给我提issue。 |
我发现原文的issue里已经有了对这个问题的讨论。而且有人发现使用 |
看了satwikkansal/wtfpython#100 (comment) 这个comment感觉更有意思了,请看Python 3.7.1中下面的示例:
So interesting, but why? |
这个是由于python会在一开始就把一定范围内的数都创建好。 如果你要创建的数在这个范围内,就直接引用python准备好的对象,不再新建,超出这个范围就会新建对象。而257刚好朝纲。 我找到一篇比较好的解释,你可以看看。 |
@leisurelicht 好的,谢谢。PS: 你这篇解释文章是刚写的吧,还热乎着😅 |
以前从知乎上转下来的,但是都存在本地。为了有个稳定的链接能给你看才上传。 |
Python 3.6.8 (default, Apr 11 2019, 11:52:43) In [4]: a = 257 In [7]: a = -5 In [10]: a = -6 who can tell me why? |
Maybe you need sure your keyboard in English.
jiangbo721 <notifications@github.com>於 2020年1月6日 週一,上午1:06寫道:
… Python 3.6.8 (default, Apr 11 2019, 11:52:43)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.10.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: a = 256
In [2]: b = 256
<https://www.google.com/maps/search/2%5D:+b+%3D+256?entry=gmail&source=g>
In [3]: a is b
Out[3]: True
In [4]: a = 257
In [5]: b = 257
<https://www.google.com/maps/search/5%5D:+b+%3D+257?entry=gmail&source=g>
In [6]: a is b
Out[6]: False
In [7]: a = -5
In [8]: b = -5
In [9]: a is b
Out[9]: True
In [10]: a = -6
In [11]: b = -6
In [12]: a is b
Out[12]: False
who can tell me why?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#13?email_source=notifications&email_token=ALIWXUTBQUYMIEB4ZP6GQPDQ4LC5PA5CNFSM4G72W252YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIEQLGA#issuecomment-571016600>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALIWXUSZRDLS5IAHHFYX3D3Q4LC5PANCNFSM4G72W25Q>
.
|
|
首先,感谢作者的辛勤劳作,实践中发现Strings can be tricky sometimes/微妙的字符串 *中第2段代码段最后一条示例在我的环境中的运行结果与文中恰恰相反,原文中是这样的:
我的环境中是这样的:
我的操作环境:windows 10企业版(64位操作系统,基于x64处理器),Python 3.7.1(64位)。
请查证。
The text was updated successfully, but these errors were encountered: