Python data type

Source: Internet
Author: User

Basic types of primary knowledge data

Generally divided into two parts:

1, Single value:

Number:

Integral type :

For The three-position system, the length is -2**31~2**31-1

For The system, the length is -2**63~2**63-1

Long Integer type:

Under python , there is no limit to the range of long integers

Floating point type:

Numbers with decimals

Plural:

That is, the real part and the imaginary part

Boolean type :

True (1)

False (0)

string :

"hello,world"

%d: represents an integer,%s: represents a string,%f: represents a floating-point number

1. Formatting of strings

Method One:

Take the placeholder %s out and replace it with "TOM", the format of which is appropriate for a situation that contains a placeholder

If there are more than two, it can be expressed as:

The contents in parentheses are written in the order of the placeholders.

Method Two:

2. Indexes and slices

3, the length of the index

4. Remove Space

5. Segmentation

String segmentation, you can specify any separator to split, the result of the split is a list.

2. Collection:

List:

A collection of elements in brackets, for example:name_list = ["Tom", "Tony"]

1. Index

2. Slicing

Slices are the same as strings

3,append, with append

3. Delete

4, length, as well as string use len

5. Turn the list into a string

6, including

Meta-group:

because tuples cannot be modified, tuples cannot be appended, deleted, or modified.

1. Indexes and slices

2. Length

3, including

4. Circulation

Distinguishing between continue and break can be seen with Eclipse plus breakpoints.

Dictionary:

1,unordered, key-value pairs, enclosed in curly braces {keys:values}

2.keys ()------> is List

3.values------> is a list

4,items ()-----> only used for the for loop, you can output the content to the for key and value

Summary:

1) The list can be modified, the tuple cannot be modified. *****

2) strings, lists, tuples common features: indexes, slices, lengths, inclusions, loops.

3) string modification is formatted with two methods, placeholder and {0},{1} ...

4) string modification will re-open memory space, memory address changes

5) The modified memory address of the list is unchanged.

6) Remove space with strip

7) contains the in

8) list becomes string with join

9) format formatted with format

10) Length with Len

11) for The For loop, distinguish between continue and break,continue is to end this cycle, and break is to jump out of the loop.

Dictionary is unordered and is composed of key-value pairs.

dictionary keys with keys ( ), values (), key values in the dictionary contents items ()

The items () inthe dictionary are only used in the For loop.

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.