-1
我正在讀取一個文件並嘗試將一個字節值與我的測試變量進行比較。我的比較總是錯誤的,因爲我沒有返回預期值。Python3 - 字節讀取不返回期望值
我的代碼:
def grey(self, varexec):
offsets = [0x388e93]
write = b'\x02'
test1 = b'\x02'
test2 = b'\x30'
test3 = b'\x10'
test4 = b'\x00'
for offset in offsets:
with open(varexec, 'rb') as offsetwriter:
offsetwriter.seek(offset)
offsetwriter.seek(6,1)
print(offsetwriter.read(2))
我希望打印(offsetwriter.read(2))返回 B '\ X14' 按以下,但事實並非如此。沒有這個,我不能使用if語句,因爲它總是返回false,從而導致else。
CPU Disasm
Address Hex dump Command Comments
00788E93 |. 6A 01 PUSH 1 ; |Arg8 = 1
00788E95 |. 6A 0C PUSH 0C ; |Arg7 = 0C
00788E97 |. 51 PUSH ECX ; |Arg6
00788E98 |. 8D50 14 LEA EDX,[EAX+14] ; |
00788E9B |. 6A 30 PUSH 30 ; |Arg5 = 30
00788E9D |. 52 PUSH EDX ; |Arg4
00788E9E |. 68 0C030000 PUSH 30C ; |Arg3 = 30C
00788EA3 |. 50 PUSH EAX ; |Arg2 => [LOCAL.1455]
00788EA4 |. 68 8F020000 PUSH 28F ; |Arg1 = 28F
當我運行我的腳本,我得到:
b'P\x14'