- Code: Select all
path = "C:/Users/blah/Documents/Blah/ParsePractice/"
fileo = "C:/Users/blah/Documents/Blah/ParsePractice/out.txt"
info = 'kadiwekjkhafhekihwaieirwqyerywqyqrywqryiqoryeioyqwryeyeywqeejlcksahfioheo'
for r,d,f in os.walk(path):
for files in f:
if '.txt' in files:
f = open(fileo, 'w')
I have this code and its sloppy and ugly but I'm a beginner. I need to read through all the files in the path designated to search for all .txt files, which I can do no problem. However, in my writeToFile function i need to write every file that ends in .txt to it. I dont know how to take every file from the first function and pass it through the second function to display every filename. Some help would be fantastic. Thank you in advance.