Python 操作一个64bit转成三个21bit并最后转成16

``

    for i in range(0, 64, stride):		 
    targetData = int(struct.unpack(dataFormat, fileDatas.read(stride))[0])
    # test = bitarray()
    # test=targetData
    num1 = targetData & 0x1fffff
    num2 = targetData & 0x3FFFFE00000
    num3 = targetData & 0x7FFFFC0000000000
    # num4 = num1 & 0x1fffe
    # print test
    print 'num1', '{:#x}'.format(num1)
    print 'num2', '{:#x}'.format(num2)
    print 'num3', '{:#x}'.format(num3)
    seek += stride
    fileDatas.seek(seek)

``

你可能感兴趣的:(Python)