1 def setbit(x, y):
2 """
3 设置位(1)
4 :param x:
5 :param y:
6 :return:
7 """
8 y = y - 1
9 return x | (1 << y)
10
11
12 def resetbit(x, y):
13 """
14 重置位(0)
15 :param x:
16 :param y:
17 :return:
18 """
19 y = y - 1
20 dt = ~(1 << y)
21 return x & dt
22
23
24 def getbit(x, y):
25 """
26 获取某位值(1或0)
27 :param x:
28 :param y:
29 :return:
30 """
31 y = y - 1
32 return x & (1 << y)