首页 > 解决方案 > 如何在python中查看文件的内容

问题描述

我正在尝试在我的文件中添加一个新帐户,该帐户已经包含其他帐户的用户名和密码,之后我只想查看新添加的帐户或文件的内容,但彼此之间有一定的距离:

编号 账户名 用户名 密码

1 Facebook 管理员 123admin

2 谷歌用户 123user

以下是我在文件中添加新帐户的代码:

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()

如何仅在我的文件中查看新帐户?

标签: pythonfunctionif-statementauthenticationview

解决方案


推荐阅读