Data Type in python, python Data Type

Source: Internet
Author: User

Data Type in python, python Data Type

1. Number
Integer int: for example, 2
Long: A long integer.
Floating point float: 3.23 and 52.3E-4. E indicates the power of 10. Here, 52.3E-4 indicates 52.3*10-4
Plural complex :(-5 + 4j) and (2.3-4.4.7), where-5 and 4 are real numbers and j are virtual numbers.

2. Boolean Value
True or false 1 or 0

3. String
Definition: it is a collection of ordered characters. It is used to store and represent basic text information ''or" ". The content contained in it is called a string.
Supplement: the single and double quotation marks of a string cannot cancel the meaning of special characters. If you want to cancel the special meaning of all characters in the double quotation marks, add r before the quotation marks, for example, name = r'l \ thf'
Common functions: Remove blank, split, length, index, and slice

4. List
Definition: separated by commas (,) in [], stores various data types by index. Each position represents an element, and the subscript starts from 0.
Create a list: name_list = ['M', 'seven', 'Eric ']
Basic operations: Index, slice, append, delete, length, slice, loop, including

 

5. tuples (unchangeable List)

Create tuples: ages = (11, 22, 33, 44, 55)

 

6. Dictionary (unordered)

Definition: {key1: value1, key2: value2}, key-value structure, key must be hash

Create a dictionary: person = {"name": "mo", 'age': 18}

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.