The difference between the python and the variable immutable object

Python is immutable objects: int, float, str, tuple, bool

Python variable objects: list, dict, set

Immutable objects:

  a = 5 PK a = 4: 5 and the memory address in the address memory 4 is different

Variable Object:

  list = [1, 2, 3, 4] PK list.append (5, 6): This is the list memory address is the same

* And placed dict tuple in the set or list of each of the objects are used as the key. Such as (1,2,3) may be, but (1, [2,3]) can not be variable [2,3]

* Add with update set collection (), by deleting remove ()

  Delete list operation pop (), was added append (), extend (), delete remove () is to remove the element e

  add operation dict dict [ ''] = '', remove pop

Guess you like

Origin www.cnblogs.com/HannahGreen/p/12128835.html
Recommended