Python Forum
str.find() not returning correct index. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: str.find() not returning correct index. (/thread-29083.html)

Pages: 1 2


RE: str.find() not returning correct index. - DreamingInsanity - Aug-18-2020

(Aug-18-2020, 05:01 PM)bowlofred Wrote: I can't confirm this will work, since I don't have your original (non-ascii) file, but this code does the reads/compares in binary and works on the ascii snippet you gave.

The reason I worked it in hex is because when read the file in binary mode, I get:
Output:
\x15\x93\x11\x04\x00H\x8b\x02H\x89E\xf81\xc0H
and so on. I think it's just easier to work in hex especially since you can convert bytes to hex anyway.