- Compared with list, Dict has the following features:
- The speed of finding and inserting is very fast and will not slow with the increase of key;
- It takes a lot of memory, and it wastes a lot of memory.
And the list is the opposite:
- The time to find and insert increases as the element increases;
- Small footprint and little wasted memory.
So, Dict is a way of exchanging space for time.
Dict can be used in many places where high-speed lookups are needed, almost everywhere in Python code, it is important to use dict correctly, and the first thing to keep in mind is that the Dict key must be an immutable object .
- Set to create a set, you need to provide a list as an input collection
s = set([1, 1, 2, 2, 3, 3])
s.add(key) s.remove(key)
set可以看成数学意义上的无序和无重复元素的集合,因此,两个set可以做数学意义上的交集、并集等操作:
交集& 并集|
Dictionary
d={' key ': value, ' key ': Value ...}
d[' key ']
Set
to create a set, you need to provide a list as an input collection
S=set ([1,1,1,2,3,...])
S.add (Element)
S.remove (...)
List
#感觉更像是数组, variable-length arrays
list=[' element1 ', ' Ele2 ',...] Can Countdown List[-1] ...
tuple= (' ele_1 ', ' ele_2 ',...)
Built-in function hex (number)
#转换为十六进制数
Python Learning 2