I have two files. File A has some entries in each line and I need to find if any entry is found in File B. Here is my script (using two functions):
def readB(x):
with open('B.txt') as resultFile:
for line in resultFile:
if x in line:
print x
def readA():
with open('A.txt') as bondNumberFile:
for line in bondNumberFile:
readB(line)
readA()
This script finds the first entry in second file and then does not finds the next one. What might be wrong here?
File A looks like this:
122323
812549
232335
921020
and File B looks like this:
696798 727832 750478 784201 812549 838916 870906 890988 921020
697506 727874 751037 784955 813096 838978 872494 891368 921789
696798 727832 750478 784201 812549 838916 870906 890988 921020
697506 727874 751037 784955 813096 838978 872494 891368 921789
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…