Python built-in type

Source: Internet
Author: User

I. Overview of Python built-in types:

(1) Main data types include: Numerics (number), sequences (sequence), ings (ing), classes, instances and exception.


(2) Features: All standard objects can be used for Boolean testing, compared between the same type, and converted to string (using the built-in function repr (obj) or str (obj )).

* Any object can test the true value in an if, while, or Boolean expression. The following values are considered false (others are true ):


* Boolean operator:


* Python has eight comparison operators with the same priority (higher than boolean operators ): <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + pgltzybzcm9 "http://www.bkjia.com/uploadfile/Collfiles/20131223/20131223095211300.jpg" alt = "">

(3) classification of standard types:

* Variable type: Numbers and dictionaries

* Unchangeable types: Numbers, strings, and tuples


2 Numeric (number) type -- int, float, complex

(1) Integers (integer ):

(2) Floating point number (double-precision Floating point type): usually implemented using double in c.

(3) Complex number (plural ):

* Example: comp = 12 + 2j

* Note: The imaginary part must have a suffix j or J.

* You can use *. real to return the real part; *. imag to return the virtual part.


Trisequence Sequence type:

(1) python has six sequence types: strings, list, tuples, range, byte sequences (bytes object), and byte arrays (bytearray objects ).

(2) String

(3) List

(4) tuples


Four Set types:

(1) The set object is an unordered hash object.

(2) There are two built-in set types: set and frozenset.

* Set is a variable set: You can add or delete elements, but not hash elements.

* Frozenset is an unchangeable set: It can be hashed.


Five ing types -- dict:


Six other built-in types:



























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.