Python Forum
str.find() not returning correct index.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
str.find() not returning correct index.
#11
(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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Find index value in List Martin2998 3 772 May-12-2020, 02:17 PM
Last Post: deanhystad
  How to find something in a list using its index rix 1 680 Dec-20-2019, 04:12 PM
Last Post: stullis
  Find index of missing number parthi1705 3 1,287 May-07-2019, 10:52 AM
Last Post: avorane
  Function not returning correct value ActualNoob 3 994 Jan-11-2019, 12:35 AM
Last Post: stullis
  How Do I find Index of a character in string? ilcaa72 5 1,563 May-23-2018, 11:44 PM
Last Post: wavic
  find the index of "Annual" in spell_list nikhilkumar 1 3,682 Jul-12-2017, 04:56 PM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020