python - Confusion about string find? -
I have a list of data that I want to find.
Name, address the age of the family members of the Doubt etc.
I want to search through the lines of data so that I can stop searching, 'but after the name to customize the search appears. I believe I want to use this command:
str.find (sub [, start [, end]])
I'm having trouble writing the code in this structure though. What tips do you make for string to work?
Here are some sample data:
Bennett, John, 17054099 "," 5 "," 156323558 "," - "," 0 ", 714 // Menendez "Juan, 7730126", "5", "158662525" 11844 // Brown, Jamal, "9", "2296, 92", "+", "0", "4432 //
/ Pre>The idea is that I want to search my program only for "," and do not want to search through the remaining big lines.
Edit. So this is my code .
I just want to find the lines from the first comma in PurataSatet. It is confused about how to implement the existing code.
For the line in the full set,counter = 1: print counter counter + = 1 for matching t: If line in t : Smalldataset.write (line)
If I understand your glasses correctly For fasting in the list: firstcomma = thestring.find (',') Havename = thestring.fin D (name, 0, first column) if havename> = 0: print "Found name:", dostring [: first conma] Edit : Edit the OP Q, this will be something like this:
Counter = 1 for line in full set : Print Counter Counter + = 1 firstcomma = thestring.find (',') havename = thestring.find (T, 0, the first conma) if the hayendam & gt; = 0: smalldataset.write (line)
Of course, using the counter
is unpredictably low-level, and will be a better eqv
counter, line in enumerate (fullsets): print counter + 1 first comma = thestring.find (',') havename = thestring.find (T, 0, first column) if havename & gt; = 0: smalldataset.write (line)
But this does not affect the question as asked.
Comments
Post a Comment