简体   繁体   中英

Different Object Identities on Different IDEs in Python

I know that the title is a bit strange, but I was trying some things on my own and by the way, I am a beginner who is currently learning Python.

My problem is, I've tried the same thing on different IDEs and they gave me different results. Jupyter shows me that two different variable names attached to the integer 750 have two different identities (I've made the assignments separately).

But when I try this in PyCharm, two different variable names attached to the integer 750 are giving the same identity. What causes this difference between two IDEs? What am I missing? Which one should I accept?

I've tried this experiment with strings.

for example ' abc ', and there is no problem with strings

在此处输入图像描述 在此处输入图像描述

The built-in Python id function just returns the memory address of that specific object (in Python everything is an object). So there is no guarantee about the value that will be returned from this function. If you rerun PyCharm or restart your Jupyter instance you will get different results almost everytime.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM