Coder Social home page Coder Social logo

Comments (4)

qiwsir avatar qiwsir commented on July 3, 2024

请阅读:https://github.com/qiwsir/StarterLearningPython/blob/master/103.md

2015-08-20 23:01 GMT+08:00 wanghaisheng [email protected]:

id(3)
140396202092696
id(3.0)
140396281118032
id(3.00)
140396281118032
id(3.000)
140396281118032
id(3.01)
140396281118032
id(3.001)
140396281118032
id(3.011)
140396281118032

为什么 3.01 3.001 3.011会是一样的值呢
python -V
Python 2.7.10


Reply to this email directly or view it on GitHub
#22.

QiWei

from starterlearningpython.

wanghaisheng avatar wanghaisheng commented on July 3, 2024

有没有103中那样类似解决除法的模块 来处理id这个问题呢

from starterlearningpython.

Eric-M-Zhu avatar Eric-M-Zhu commented on July 3, 2024

id(任意浮点数) 的值都是一样的,我觉得这个语句应该是把浮点数赋值给一个临时变量,然后id(临时变量)。所以id(3.0),id(4.0)等的结果都一样。

比如下面,开始id(3.0)和id(4.0)值都一样,再声明一个浮点数变量ff,ff的id值也是一样。再执行一句id(7.0),id值就变了。前俩句,应该使用了同样的临时变量,声明ff时,把临时变量id给了ff,后面只能再分配一个临时变量了。

id(3.0)
140303047617784
id(3.1)
140303047617784
ff = 6.0
id(ff)
140303047617784
id(7.0)
140303047617808

from starterlearningpython.

wanghaisheng avatar wanghaisheng commented on July 3, 2024

有一点明白了 谢谢

from starterlearningpython.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.