Remember the first question --python file can not be written

import getpass username = input ( "please input your name:") password = getpass.getpass ( "please input the password:") fo = open ( "homework01.txt", "a +") print (username) print (password) fo.write (username) fo.write (password) fo_read = fo.read () print (fo_read) fo.close () Console: please input your name: Ansue please input the password: 123456 Ansue 123456 ..... hello ------------------------------ can not be written in a document written hello ok, but with a + mode still will reset the data inside, well, first encountered the problem turned out to be a long time before and has not been resolved, at a loss

Guess you like

Origin www.cnblogs.com/ansue-home/p/11886460.html