Writing file | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Writing file

Is it possible to write in 2 text file at the same time? If yes, how?

26th Feb 2021, 9:59 AM
Belbeart
Belbeart - avatar
8 Answers
+ 1
share your code to get further help ^^
27th Feb 2021, 11:11 AM
visph
visph - avatar
+ 1
# just use two (or more) file handlers: file0 = open('file0.txt','w') file1 = open('file1.txt','r') file2 = open('file2.txt','r') # do stuff with files... file0.close() file1.close() file2.close() # or even: with open('file0.txt') as file0: with open('file1.txt') as file1: with open('file2.txt') as file2: # do stuff with files...
26th Feb 2021, 8:52 PM
visph
visph - avatar
0
Your question lack some necessary details :- 1) language you want to use ? 2) what do you exactly mean by "at the same time" ? 3) what kind of files are these ?
26th Feb 2021, 10:10 AM
Arsenic
Arsenic - avatar
0
in python.
26th Feb 2021, 10:10 AM
Belbeart
Belbeart - avatar
0
can I “merge”, create a new text file by using 2 text file as arguments?
26th Feb 2021, 10:12 AM
Belbeart
Belbeart - avatar
0
Well... technically yes
26th Feb 2021, 2:34 PM
Redacted
Redacted - avatar
0
how
26th Feb 2021, 5:09 PM
Belbeart
Belbeart - avatar
0
thanks, but it’s not working
27th Feb 2021, 9:48 AM
Belbeart
Belbeart - avatar