0

is it posiblle to make this more compact?

file1=open(filename1, 'r', encoding='utf-8') file2=open(filename2, 'r', encoding='utf-8') text1=file1.read() text2=file2.read() file1.close() file2.close()

8th Apr 2022, 1:20 PM
Artur
Artur - avatar
4 Answers
+ 1
thank you, i have 1 question tho. we dont need to close the file if we open it using 'with'?
8th Apr 2022, 1:39 PM
Artur
Artur - avatar
0
thank you :)
8th Apr 2022, 1:44 PM
Artur
Artur - avatar