Answer the question
In order to leave comments, you need to log in
Throws MemoryError?
with open(r'C:\Users\AKSHIN\Downloads\errr.txt','r',encoding='utf-8')as f:
z = f.read().split('\n')
for line in z:
print(line)
Answer the question
In order to leave comments, you need to log in
with open(file_name, 'r') as f:
for line in f:
# your code
MemoryError - an exception that occurs in non-critical cases of exhaustion of free memory. You can handle it by removing objects from memory.
In general, you are doing bullshit. Output 6 million lines to the console. Your life is not enough to read every line. Output only those lines that contain the desired text (you can add more problems for yourself, use regular expressions - this is from a bearded joke)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question