dimanche 31 octobre 2021

How to view the contents of a file in python

I am trying to add a new account in my file which already consist of a username and password of other accounts, after doing it I only want to view the new added accounts or contents of the file like this but have certain distances with each other:

No. Account Name Username Password

1 Facebook admin 123admin

2 Google user 123user

Below is my code for adding a new account in my file:

def Add_account():

    account = input("\nEnter the name of the account: ")
    username = input(f"Enter the username of your {account}: ")
    password = input(f"Enter the password of your {account}: ")
    ask = input(f"Do you want to save {account} credentials? [Y|N]: ")

    if new_ask == "Y":
        with open("info.txt", "a") as file:
            file.write("\n" + encrypt(account) + ":" + encrypt(username) + ":" + encrypt(password))
            file.close()
         
Add_account()

How can I view the new accounts only in my file?

Aucun commentaire:

Enregistrer un commentaire