Python 的 type 和 object 之间是怎么一种关系
1个回答
2017-09-25
展开全部
Objects are Python’s abstraction for data. All data in a Python program is represented by objects or by relations between objects. (In a sense, and in conformance to Von Neumann’s model of a “stored program computer,” code is also represented by objects.)
对象是Python对数据的抽象。 Python程序中的所有数据都由对象或对象之间的关系表示。(在某种意义上,并且符合冯·诺依曼的“存储程序计算机”的模型,代码也由对象表示的)。
Every object has an identity, a type and a value. An object’s identity never changes once it has been created; you may think of it as the object’s address in memory. The ‘is‘ operator compares the identity of two objects; the id() function returns an integer representing its identity.
每个对象都有一个标识,一个类型和一个值。 对象的身份一旦创建就不会改变; 你可以把它看作内存中的对象地址。'is'运算符比较两个对象的标识; id()函数返回一个表示其身份的整数。
An object’s type determines the operations that the object supports (e.g., “does it have a length?”) and also defines the possible values for objects of that type. The type() function returns an object’s type (which is an object itself). Like its identity, an object’s type is also unchangeable.
对象的类型决定对象支持的操作(例如,“它有长度吗?”),并且还定义该类型对象的可能值。type()函数返回一个对象的类型(它是一个对象本身)。与它的身份一样,对象的类型也是不可改变的。
对象是Python对数据的抽象。 Python程序中的所有数据都由对象或对象之间的关系表示。(在某种意义上,并且符合冯·诺依曼的“存储程序计算机”的模型,代码也由对象表示的)。
Every object has an identity, a type and a value. An object’s identity never changes once it has been created; you may think of it as the object’s address in memory. The ‘is‘ operator compares the identity of two objects; the id() function returns an integer representing its identity.
每个对象都有一个标识,一个类型和一个值。 对象的身份一旦创建就不会改变; 你可以把它看作内存中的对象地址。'is'运算符比较两个对象的标识; id()函数返回一个表示其身份的整数。
An object’s type determines the operations that the object supports (e.g., “does it have a length?”) and also defines the possible values for objects of that type. The type() function returns an object’s type (which is an object itself). Like its identity, an object’s type is also unchangeable.
对象的类型决定对象支持的操作(例如,“它有长度吗?”),并且还定义该类型对象的可能值。type()函数返回一个对象的类型(它是一个对象本身)。与它的身份一样,对象的类型也是不可改变的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询