-2

This is my code

f1 = open("file1.txt").read( ).splitlines( )
f2 = open("file2.txt").read( ).splitlines( )
print list(itertools.product(f1,f2))

I want to run this for all files in the directory.How to do it using python. I am unable to implement suggestions given here using glob.

1 Answers1

-1
import glob

#For any kind of file in that directory.

for file in list(glob.glob("*")):     
    # do your work

#For specific kind of file in that directory. like all .py or .txt or .csv file.. etc. 

for file in list(glob.glob("*.file extension")):
    # do your work