A specific description of the data types in the Python object

Source: Internet
Author: User
For Python, everything is an object, and all the data stored in the program is an object, and the object is created based on the class. This article mainly describes the Python object data type, the need for friends can refer to the following

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

The computer can process more than the numerical value, but also can deal with text, graphics, audio, video, web and other kinds of data, different data, need to define different data types.

Class refers to a custom type, and type refers to a built-in type. Both represent data types, and they are called different.

Each object has an identity, a type, and a value, which refers to the pointer (an in-memory address) where the object is in memory, and the built-in function ID () returns the identity of an object. The variable name is the name that refers to the specific location.

Instantiation: Creating 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 mutable object
If the object value is not modifiable, it is called an immutable object

Container: An object contains a reference to another object, such as a list.

Python is a strongly typed language in which the type of object determines the operation that the object can participate in or the method it supports, that is, the method exists in the class, and the function in the object is found in the class.
Most objects have a large number of unique data properties and methods

Properties: Object-related values, such as variable names

Method: A function that will perform certain operations on an object when called

>>> name= ' test ' >>> name.upper ()--method test>>> num = 1>>> print (num.real)--Properties Help ( Type)--View what methods or properties of a type >>> help (Type.func)--Find the usage of a method >>> Help (Str.find) Use the dot (.) operator to access the properties and methods print (obj)--See which class the object was created by >>> from twisted.internet import reactor>>> print ( Type (reactor))

Core data types

Numbers: Int,long,float,complex,bool (0:false, 1:true)

Character: Str,unicode

Listing: List

Tuples: Tuple

Dictionary: Dict

Files: File

Other: Set (set), Frozeset, class type, None

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.