Python名称和变量 [英] Python Names and Variables

查看:43
本文介绍了Python名称和变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题可能已经解决了上千次,可能是一个非常愚蠢的问题. 但是,如果您创建python variabel(name),会发生什么呢? 例如,如果您键入: x = 2 我知道Python创建了一个保存整数2的intobject.但是x实际上是指向该对象的指针吗?如果是这种情况,则此指针本身存储在哪里,并且会消耗内存吗? 再次抱歉这个可怕的问题(在电话中吮吸)和问题本身. 任何帮助都将受到高度赞赏

I know this was addressed probably a thousand times already and might be a really dumb question. But what happens exactly if you create a python variabel(name)? For example if you type : x = 2 I know Python creates an intobject which holdsthe interger 2. But the x actually is a pointer to that object ? And in case it is, where is this pointer itself stored and does it consume memory? Sorry again for this horribly typed question (sucks doing it on the phone) and the question itself. Any help is highly appreciated

推荐答案

x是一个名称.与该名称关联的值是一个表示2的int对象.其他所有内容都是实现细节,该语言本身未指定.

x is a name. The value associated with that name is an int object representing 2. Anything else is an implementation detail, not specified by the language itself.

这篇关于Python名称和变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆