python位运算

class BitManiPaulation:
    __slots__ = ['__num']
    def __init__(self,num:int):
        self.__num = num


    def get_bit(self,postistion):
        mask = 1<>=1
            print(self.__num)
        return bits[::-1]

    @property
    def bits(self):
        bin_array=bin(self.__num)[2:].zfill(16)
        a=bin_array[0:4]
        b=bin_array[4:8]
        c=bin_array[8:12]
        d=bin_array[12:16]
        return f'{self.__num}的二进制数为: {a}_{b}_{c}_{d}'




a=BitManiPaulation(12)
print(a.bits)
print(a.get_bit(4))
print(a.bits)

你可能感兴趣的:(python,开发语言)