Python Forum

Full Version: searching contents of files
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I have converted the first file into list as below:

>>> f=open("/var/tmp/out1","r")
>>> p=open("/var/tmp/input2","r")
>>> disk=[]
>>> for line in p:
...     line = line.strip()
...     disk.append(line)
now i want to search this list elements in file how i can do.Please help
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
Input code into python code tags...
[Image: python_tag2.png]
Pages: 1 2