python set list dict tuple conversion and the difference

Python provides various types of data to store a set of data items, including the sequence (a list of tuples and tuple list), mapping (e.g., dictionary dict), set set, following these several data types introduced.

 

In Python list, the main difference tuple, dict and set : tuple is an immutable list, set the Value is not a dict, list, dict and set data is variable, tuple data is immutable!

Pleasantly surprised

 

In list is the most free, you can use the index, slice, can be calculated and modification;

Tuple tuple is not free, the data can not be changed, but the list and having the same sequence, and the index may be sliced;

Dictionary dict is constituted by a random value pairs, the value of the index value can go through the key, modified data may be modified by the corresponding value Key;

set set is unordered, do not overlap, and the like are used dictionaries brackets {} represent, except that the dictionary is a key-value pair, or the set consisting of data elements or the list;

 

smell it

 

python set list dict tuple interchangeable refer to: convert between python string / list / tuple / Dictionary

 

you may also like:

1.pycharm Configuration Template Development

2.python list comprehensions

3.python dictionary derivations

4.python anonymous function lambda

 

Reproduced please specify : ape say Python  »  Python and the difference between the SET List dict tuple conversion


Guess you like

Origin blog.51cto.com/14531342/2475831