dimanche 17 juillet 2016

Python: Finding a substring within a string from a list, but saving the substring

Basically, I have a list of substrings I am searching a string for. I'm using any() currently and doing some work if one of the words are found in the string. I want to start logging the matches to keep some stats on the matches. I am using any() right now.

Is there a way to do the same thing as any, but store the match in a variable? I'm fetching and searching up to 100 strings every 10 seconds for a list of 25-30 substrings. THe only thing I can think of is iterating through each substring in the list for each string but im not sure of the performance implications with that approach.

Aucun commentaire:

Enregistrer un commentaire