Answer the question
In order to leave comments, you need to log in
How to read text from all files in Python?
I have the following program code
from os import listdir
fileNames = listdir(r'C:\Users\sha\Desktop\27')
handleWrite = open(r'C:\Users\sha\Desktop\27\fileResult\Result.txt', 'w')
number = 0
for cycle in fileNames:
q = fileNames[number]
handle = open(r'C:\Users\sha\Desktop\27\{}'.format(q), 'r')
data = handle.read(768)
dataResult = data[755:768]
print(dataResult)
handle.close()
handleWrite.write('{}\n'.format(dataResult))
number +=1
handleWrite.close()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question