首页 > 解决方案 > 变量名的地址是什么?

问题描述

>>> x = "hello world"
>>> x
'hello world'
>>> id(x)
140461077304368

我们得到140461077304368包含的地址hello world

>>> dir()
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'x']

变量名称x在命名空间中,x地址是什么?还有一个容器包含x,容器的地址是什么?
dir()会占用内存空间,x定位在空间中,该空间的地址是什么?诸如__spec__then 之类的项目的地址是什么?

标签: python-3.xvariablesmemory-address

解决方案


推荐阅读