Python based Python data structure

1. List:

Lists are the most basic data structure in Python. Each element in the list is assigned a number-its position, or index, the first index number is 0, the second index number is 1, and so on.

2. Tuple:

Tuples are similar to lists, except that the elements of tuples cannot be modified; parentheses are used for tuples, and square brackets are used for lists.

3. Dictionary:

The dictionary is another variable container model, and can store any type of object. Each key (key => value) value of the dictionary is separated by a colon (:), and each pair is separated by a comma (,). The entire dictionary is enclosed in curly brackets ({}). Such as: d = {key1: value1, key2: value2}

Note: The key must be unique, but the value is not necessary; the value can take any data type but the key must be immutable, such as a string, number, or tuple.

Guess you like

Origin www.cnblogs.com/elitphil/p/12749018.html