0

file handling

msg = "Hello world!" file = open("newfile.txt", "w+") amount_written = file.write(msg) print(file.read()) print(amount_written) file.close() Why can i not read and write simultaneously..how to do it...

10th Jul 2018, 8:24 AM
Anand Agrawal
4 ответов
+ 1
yes you can both read and write file using file=open("newfile.txt","r+")
10th Jul 2018, 8:28 AM
Pulkit Kamboj
Pulkit Kamboj - avatar
+ 1
it's same as asking why can't we use printf('string') instead of print('string') well,its just a notation
10th Jul 2018, 8:33 AM
Pulkit Kamboj
Pulkit Kamboj - avatar
0
ok bro thanks but please check it's not happening in my code..even I do r+
10th Jul 2018, 8:31 AM
Anand Agrawal
0
check my code and answer I am not able to read the file
10th Jul 2018, 8:34 AM
Anand Agrawal