“_io.TextIOWrapper”对象不可下标

问题描述

我在 JSON 文件中有这种用于某种登录系统的“数据库”,但我想检查某个项目是否在列表中,因此如果您想登录,可以继续

这是我的代码

if option == 'Login':
    username = pyautogui.prompt(title="Login",text="Enter your username").lower()
    with open("Cool_Database.json","r+") as DB:    # open json file and gives it the variable DB

        if username in DB["Name"]:    # You can login by typing username but it needs to be in json file same for the password
            # If username in 'database' u can enter the password that matches mask password i
            password = pyautogui.password(title="Login",text="Type your password",mask='*')
        else:
            return main()

        if password in DB["Password"]:
            # If password in list u can move on..
            while True: ...

但是,当我尝试登录时出现此错误

TypeError: '_io.TextIOWrapper' object is not subscriptable

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)