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.
#7
I keep coming here to post an interring discovery and then keep realising I've been an idiot.

I said that it was a few tens of characters off, which it was. I first tried using a substring rather than seeking to the index and it didn't change anything. I then thought about using a substring with the file opened in ascii encoding (like at the beginning), not latin-1. Well, this worked and I was in the middle of typing a reply when I realised that I open the file twice and I've only ever been chasing the encoding on one of them. The other has always been ascii which is what was causing the string to be a few characters off. It is now all working which is amazing.
Reply


Messages In This Thread
RE: str.find() not returning correct index. - by DreamingInsanity - Aug-18-2020, 10:25 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  labels.append(self.classes.index(member.find('name').text)) hobbyist 1 1,974 Dec-15-2021, 01:53 PM
Last Post: deanhystad
  pandas pivot table: How to find count for each group in Index and Column JaneTan 0 3,401 Oct-23-2021, 04:35 AM
Last Post: JaneTan
  Find index value in List Martin2998 3 2,854 May-12-2020, 02:17 PM
Last Post: deanhystad
  How to find something in a list using its index rix 1 1,775 Dec-20-2019, 04:12 PM
Last Post: stullis
  Find index of missing number parthi1705 3 3,203 May-07-2019, 10:52 AM
Last Post: avorane
  Function not returning correct value ActualNoob 3 2,770 Jan-11-2019, 12:35 AM
Last Post: stullis
  How Do I find Index of a character in string? ilcaa72 5 3,832 May-23-2018, 11:44 PM
Last Post: wavic
  find the index of "Annual" in spell_list nikhilkumar 1 5,690 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