Python object data type, python Data Type
For python, everything is an object, all the data stored in the program is an object, and the object is created based on the class
Computers can process a variety of data, such as text, graphics, audio, video, and web pages. Different data types need to be defined.
Class refers to the custom type, and type refers to the built-in type. Both of them indicate different data types.
Each object has an identity, a type, and a value. The identity refers to the pointer of the object in memory (the address in memory), and the built-in function id () returns the identity of an object. The variable name is the name that references the specific location.
Instantiate: create a specific type of object
After an instance is created, its identity and type cannot be changed
If the object value can be modified, it is called a variable object.
If the object value cannot be modified, it is called an immutable object.
Container: an object contains references to other objects, such as a list.
Python is a strongly typed language. The type of an object determines the operations that the object can participate in or the methods it supports, that is, the methods exist in the class, all the functions in the object are found in the class.
Most objects have a large number of unique data attributes and methods.
Attribute: The value related to the object, such as the variable name.
Method: functions that perform certain operations on objects when called
>>> Name = 'test' >>> name. upper () -- Method TEST >>> num = 1 >>> print (num. real) -- property help (type) -- view the methods or properties of a type >>> help (int) help (type. func) -- find the usage of a method >>> help (str. find) usage point (.) you can use the print (type (obj) operator to access attributes and Methods. You can view the class created by the Object> from twisted. internet import reactor> print (type (reactor ))
Core Data Type
Number: int, long, float, complex, bool (0: False, 1: True)
Character: str, unicode
List: list
Tuples: tuple
Dictionary: dict
File: file
Others: set, frozeset, class type, None
The above is the data type in the Python object introduced by the small editor. I hope it will be helpful to you. If you have any questions, please leave a message. The small editor will reply to you in time!