集合介绍:
集合用法:
s = {}
type(s)<class 'dict'>
s={1}
type(s)
<class 'set'>
l=[1,22,36,54,1,3,2,22]
set(l)
{1, 2, 3, 36, 54, 22}
s={1,2,3,4,5,2,5}
s
{1, 2, 3, 4, 5}
s.add(5)
s
{1, 2, 3, 4, 5}
s.add(6)
s
{1, 2, 3, 4, 5, 6}
s.pop()
1
s.pop()
2
s
{3, 4, 5, 6}
s.add(1)
s.add(2)
s
{1, 2, 3, 4, 5, 6}
s.remove(7)
Traceback (most recent call last):
File "<input>", line 1, in <module>
KeyError: 7
s.remove(5)
s
{1, 2, 3, 4, 6}
s.discard(7)
s
{1, 2, 3, 4, 6}
s.discard(1)
s
{2, 3, 4, 6}
s.update(1,2,5,7,8)
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: 'int' object is not iterable
s.update([1,2,5,7,8])
s
{1, 2, 3, 4, 5, 6, 7, 8}
s.add(1,2,3,4)
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: add() takes exactly one argument (4 given)
s
{1, 2, 3, 4, 5, 6, 7, 8}
s.clear()
s
set()
help(s.update())
Help on NoneType object:
class NoneType(object)
| Methods defined here:
|
| __bool__(self, /)
| self != 0
|
| __new__(*args, **kwargs) from builtins.type
| Create and return a new object. See help(type) for accurate signature.
|
| __repr__(self, /)
| Return repr(self).
集合的交集差集:(intersection、|这俩是交集;)
集合的并集:
:两集合相交集合之外的集合
包含:
8进制和16进制:
2进制 : bin(num) ; 8进制 : oct(num) ; 16进制 : hex(num) ; ASCII码 : chr()
二进制与十六进制转换:
https://jingyan.baidu.com/article/47a29f24292608c0142399cb.html