Python data type

Source: Internet
Author: User

1.Python supports five basic number types, three of which are integral types
(1) Int integer
(2) Long integer type
(3) Boolean bool
(4) floating-point type floating-point
(5) plural complex


Model 2.int
Standard integer type
(1) Decimal
(2) 2 binary is starting with 0b:
For example: 0B11 represents 3 of the decimal
(3) 8 binary is preceded by 0:
For example: 011 indicates a decimal 9
(4) 16 binary is starting with 0x:
For example: 0x11 represents 17 of the decimal

3. Digital


4. Sequence
(1) string
Use raw String (original string)
>>> Myfile=open (R ' C:\new\test.txt ', ' W ')
Use the escape character \
>>> myfile=open (' C:\\new\\test.txt ', ' W ')

(2) List
(3) Meta-group

5. Mapping type

To create a dictionary:
>>> a = Dict (one=1, two=2, three=3)
#dict () factory functions are used to create dictionaries
>>> B = {' One ': 1, ' both ': 2, ' Three ': 3}
>>> C = dict (Zip ([' One ', ' B ', ' three '), [1, 2, 3])
>>> d = dict ([' One ', 1), (' Three ', 3)])
>>> e = dict ({' Three ': 3, ' one ': 1, ' One ': 2})
>>> A = = b = = C = = d = E
True

6. Set (SET)
7. Documents


(1) Storage model

? Atomic Storage (scalar):

The type number of a single Literal object, String (why is the string not a container type?) Python does not have a char type)

? Container Storage (Container):

? A type list, a tuple, a dictionary that holds multiple objects


(2) Updating the model

Immutable types: Numbers, strings, tuples

Mutable type: list, dictionary
(3) Accessing the model

Direct access: Digital

Sequential access: strings, lists, tuples

Map Access: Dictionaries

Python data type

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.