python - Searching a blob for a string -
python - Searching a blob for a string -
i have base64 blob have loaded database. have decoded , need search string. blob can , contain binary (non printable) bytes.
my code far simply
for row in cursor: b = base64.standard_b64decode(row[2])
so need find position of string 'xyx' in b
a "binary blob" string in python, can utilize str.index
:
i= b.index('xyx')
i becomes value of 0-based index of position of 'xyx'
in b
. note count bytes, not characters.
you can utilize str.find
, if don't want raise exception in case 'xyx' not in b
python string search
Comments
Post a Comment