This is my code below
import re
hfile1 = open(“example1.so”, “rb”) bfile1 = hfile1.read() hfile1.close()
hfile2 = open(“example2.so”, “rb”) bfile2 = hfile2.read() hfile2.close()
afile1 = re.findall(‘[0-9A-Fa-f]{2}’, bfile1) afile2 = re.findall(‘[0-9A-Fa-f]{2}’, bfile2)
print(afile1)
print(afile2)
and this is error message below
Traceback (most recent call last): File “”, line 12, in <module> afile1 = re.findall(‘[0-9A-Fa-f]{2}’, bfile1) File “”, line 278, in findall return _compile(pattern, flags).findall(string) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
TypeError: cannot use a string pattern on a bytes-like object
How to treat the binary read as string?
submitted by /u/metalhorse209
[link] [comments]
r/learnpython This is my code below import re hfile1 = open(“example1.so”, “rb”) bfile1 = hfile1.read() hfile1.close() hfile2 = open(“example2.so”, “rb”) bfile2 = hfile2.read() hfile2.close() afile1 = re.findall(‘[0-9A-Fa-f]{2}’, bfile1) afile2 = re.findall(‘[0-9A-Fa-f]{2}’, bfile2) print(afile1) print(afile2) and this is error message below Traceback (most recent call last): File “”, line 12, in <module> afile1 = re.findall(‘[0-9A-Fa-f]{2}’, bfile1) File “”, line 278, in findall return _compile(pattern, flags).findall(string) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ TypeError: cannot use a string pattern on a bytes-like object How to treat the binary read as string? submitted by /u/metalhorse209 [link] [comments]
This is my code below
import re
hfile1 = open(“example1.so”, “rb”) bfile1 = hfile1.read() hfile1.close()
hfile2 = open(“example2.so”, “rb”) bfile2 = hfile2.read() hfile2.close()
afile1 = re.findall(‘[0-9A-Fa-f]{2}’, bfile1) afile2 = re.findall(‘[0-9A-Fa-f]{2}’, bfile2)
print(afile1)
print(afile2)
and this is error message below
Traceback (most recent call last): File “”, line 12, in <module> afile1 = re.findall(‘[0-9A-Fa-f]{2}’, bfile1) File “”, line 278, in findall return _compile(pattern, flags).findall(string) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
TypeError: cannot use a string pattern on a bytes-like object
How to treat the binary read as string?
submitted by /u/metalhorse209
[link] [comments]