Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. def file_append(username):
  2. """ This subprogram will append the username and password to the text file
  3. ‘logins.txt’
  4. """
  5.  
  6. myFile = open('logins.txt','a')
  7. # The file is opened in append mode, meaning anything written in this
  8. # procedure will not overwrite current data stored on the file.
  9. password = "Password123\n"
  10. # the variable password is set to 'Password123' so that it can be added
  11. # to the record.
  12. record = "Username: " + username + " " + "Password: " + password
  13. # Combines username and password (along with a spacer) into one variable
  14. # so it can be appended to the file more easily
  15. myFile.write(record)
  16. # The variable 'record' is appended to the file
  17. myFile.close
  18. # File is closed so that other programs or the user can now open it.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement