3
我試圖找到加載ConstBitStream文件中的特定字節:如何從給定偏移量開始在ConstBitStream中查找二進制數據?
s = ConstBitStream(filename=myFile)
found = s.find('0x4140', bytealigned=False)
這是第一個出現正常工作。發現第一個序列後,我想再次使用find
方法,但開始尋找下一個從現在偏移:
s.bytepos = position_after_the_first_occurrence + my_offset
found = s.find('0x4140', start=s.bytepos, bytealigned=False)
這似乎並沒有工作。我總是從我的二進制序列的第一次出現中獲得位置。
怎麼了?
UPDATE:(以及第二found
值s.bytepos
)
found = {tuple} (54784,)
s.bytepos = {int} 6848
:
(的第一found
值和s.bytepos
)
s.bytepos = {int} 32969
found = {tuple} (54784,)
似乎設置start=s.bytepos
不具有任何效果。
你能打印出'found'(第一個值)和's.bytepos'的值嗎? –
不要使用's.bytepos'作爲'start'參數的值,而是使用's.pos'。 – user2683246
確保'my_offset'計數字節,而不是位。請注意,'found'值是一個具有位偏移量的元組,不是字節偏移量。 – user2683246