# Equal
ai = 1
bi = 1
print(id(ai), id(bi))
# Not equal
af = 1.0
bf = 1.0
print(id(af), id(bf))
# False
float 在 Python 里面不是 immutable 的 primitive type 吗? 为啥和 int 表现的不一样呢?
7 条回复 • 2022-07-28 23:07:38 +08:00
|
1
ClericPy 2022 年 7 月 28 日 [-5, 256] 是常驻内存的
>>> a = -7 >>> b = -7 >>> a is b False |
|
4
0xo 2022 年 7 月 28 日 |
|
5
filwaline 2022 年 7 月 28 日 via Android |
推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide