Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
searching contents of files
#12
I try to read file in list and tried below code its not working.Please help.

>>> f=open("a.txt","r")
>>> p=open("b.txt","r")
>>> disk=[]
>>> for line in p:
... line = line.strip()
... disk.append(line)

for line in f.readlines():
for word in disk[0]:
if word in line:
print line
Reply


Messages In This Thread
searching contents of files - by Ahmedrhle - Jul-19-2017, 08:48 PM
RE: searching contents of files - by nilamo - Jul-19-2017, 08:52 PM
RE: searching contents of files - by Ahmedrhle - Jul-19-2017, 08:55 PM
RE: searching contents of files - by nilamo - Jul-19-2017, 08:57 PM
RE: searching contents of files - by Ahmedrhle - Jul-19-2017, 09:13 PM
RE: searching contents of files - by nilamo - Jul-19-2017, 09:29 PM
RE: searching contents of files - by Ahmedrhle - Jul-19-2017, 09:37 PM
RE: searching contents of files - by nilamo - Jul-19-2017, 09:39 PM
RE: searching contents of files - by Ahmedrhle - Jul-19-2017, 09:50 PM
RE: searching contents of files - by DeaD_EyE - Jul-20-2017, 09:30 AM
RE: searching contents of files - by Ahmedrhle - Jul-20-2017, 02:32 PM
RE: searching contents of files - by Ahmedrhle - Jul-20-2017, 05:22 PM
RE: searching contents of files - by DeaD_EyE - Jul-20-2017, 07:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  splitting file into multiple files by searching for string AlphaInc 2 986 Jul-01-2023, 10:35 PM
Last Post: Pedroski55
  Searching for specific word in text files. JellyCreeper6 1 1,775 Nov-03-2020, 01:52 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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