itappspace |
python的变量是指向一个对象吗?比如是数字102024-12-14 7:55 12 0In Python, a variable is not exactly a pointer to an object, but rather a name bound to an object. This is known as "name binding" or "symbolic reference". When you assign a value to a variable, such as In other words, Here's a key difference:
For example: x = 10 y = x x += 1 print(y) # still prints 10 As you can see, changing the value of So, in summary, in Python, a variable is a name bound to an object, not a pointer to an object. This distinction can be important when working with Python, especially when dealing with mutable objects or object references. 💡 |
回复 | |
itappspace |
发表于 2024-12-14 08:11:06 Python id() 函数 Python 内置函数 Python 内置函数 描述 id() 函数返回对象的唯一标识符,标识符是一个整数。 CPython 中 id() 函数用于获取对象的内存地址。 语法 id 语法: id([object]) 参数说明: object -- 对象。 返回值 返回对象的内存地址。 |
回复 | |