New submission from Anmol Kejriwal <kejriwalan...@gmail.com>:
The file modes a+, r+, w+ should read and write both. But a+ and w+ modes are not reading anything from the file. The RUN for the program is successful, but there is no output from the program. Below is a simple program: file=open("abcd.txt","w+") l=["This is python.\nThis is an easy language.\nAnyone can learn this easily"] file.writelines(l) file.close() file=open("abcd.txt","a+") #Replacing with w+ also doesn't read. file.write("123") t1=file.read() #This read() does not work. print(t1) #Does not print anything here. file.close() In r+ mode, it should write in the file without truncation and read it too. Instead, it is removing from the file, the equal number of characters I am trying to write in the file. Below is the program: file=open("abcd.txt","w+") l=["This is python.\nThis is an easy language.\nAnyone can learn this easily"] file.writelines(l) file.close() file=open("abcd.txt","r+") file.write("123") t1=file.read() print(t1) Output for this is: s is python. This is an easy language. Anyone can learn this easily ---------- components: Windows messages: 357609 nosy: anmolkejriwal, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: File modes with '+' character does not give expected output type: behavior versions: Python 3.6, Python 3.7, Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38935> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com