loop though textfiles

Martin Johansson 045521104 at telia.com
Mon May 14 10:42:22 EDT 2001


Hi!
How can I do if I want to do a searchmethon on several textfiles? Can I use
fileinput and how should I do?
It must be some kind of loop.
this is the lines I want to do on every textfile.

word = raw_input("skriv ett ord: ")
c=open('01_10_Maj_12_360,2183,122_nyheter_1022,00.txt', 'r')
textstring = c.read()
index = string.find(textstring, word)
index = string.find(string.lower(textstring), string.lower(word))
if index > 0:
    print "do exists"
else:
    print "do not exist"

Martin Johansson
pt00mjo at student.bth.se






More information about the Python-list mailing list