[Introduction to Python data types]

Python has five standard data types:

Numbers

String (string)

List

Tuple (tuple)

Dictionary (dictionary)

 

Four different number types:

int (signed integer)

long (long integer [can also represent octal and hexadecimal])

float

complex (plural)

 

Lists are marked with [ ] and are the most common composite data type in python.

The variable [head subscript: tail subscript] can also be used to cut the values ​​in the list, and the corresponding list can be intercepted. The default index from left to right starts with 0, and the default index from right to left starts with -1. The subscript can be Empty means to take the head or tail.

The plus sign + is the list concatenation operator, and the asterisk * is the repeat operation.

 

 

Tuples are identified with "()". Inner elements are separated by commas. But tuples cannot be assigned twice, and are equivalent to read-only lists.

 

 

Dictionary (dictionary) is the most flexible built-in data structure type in python other than lists. A list is an ordered collection of objects, and a dictionary is an unordered collection of objects.

The difference between the two is that the elements in the dictionary are accessed by keys, not by offsets.

Dictionaries are identified with "{ }". A dictionary consists of an index (key) and its corresponding value value.

 

【Summarize】

String operations have basic functions and do not need to perform splicing and traversal operations by yourself.

Lists are marked with "[ ]" similar to arrays in C language.

Tuples are identified with "( )". Inner elements are separated by commas. But tuples cannot be assigned twice, and are equivalent to read-only lists.

Dictionaries are identified with "{ }". A dictionary consists of an index key and its corresponding value value.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326275646&siteId=291194637