如何修改Python代码以允许accounts.json文件中有两个以上的帐户

fhity93d  于 2023-03-28  发布在  Python
关注(0)|答案(1)|浏览(82)

整个患者年的巴氏蛋白:https://pastebin.com/CiSnwSAv我有一个accouns.json文件,它可以与PY文件一起使用,但是当我尝试在accounts.json中添加超过2个帐户时,py文件给我一个错误。py文件应该将电子邮件粘贴到登录页面的文本框中。它可以做所有它应该做的事情,但是正如github repo所述,它可以与多达6个帐户一起使用,我希望我的问题是准确和可以理解的。
accounts.json文件在2个帐户下工作正常

[
  {
    "username": "MY@gmail.com",
    "password": "12345678765"
  },
  {
    "username": "MY@outlook.com",
    "password": "123213423"
  }
]

这是PY文件中可能导致问题的部分

def loadAccounts():
    global ACCOUNTS
    if ARGS.accounts:
        ACCOUNTS = []
        for account in ARGS.accounts:
            ACCOUNTS.append({"username": account.split(":")[0], "password": account.split(":")[1]})
    else:
        try:
            ACCOUNTS = json.load(open("accounts.json", "r"))
        except FileNotFoundError:
            print("Please create an `accounts.json` file and try again.")            
            prPurple(f"""
        [ACCOUNT] Accounts credential file "accounts.json" created.
        [ACCOUNT] Edit with your credentials and save, then press any key to continue...
            """)
            input()
            ACCOUNTS = json.load(open("accounts.json", "r"))

但只要我添加了多个帐户,

[
  {
    "username": "MY@gmail.com",
    "password": "34324214"
  },
  {
    "username": "MY@outlook.com",
    "password": "q231231313"
  }
{
    "username": "MY@outlook.com",
    "password": "123423123"
  }
]

这种情况发生,

C:\Users\NHS\Downloads\MRS-main\MRS-main> **python C:\Users\NHS\Downloads\MRS-main\MRS-main\MRSB.py**
Traceback (most recent call last):
  File "C:\Users\NHS\Downloads\MRS-main\MRS-main\MRSB.py", line 1763, in <module>
    main()
  File "C:\Users\NHS\Downloads\MRS-main\MRS-main\MRSB.py", line 1740, in main
    loadAccounts()
  File "C:\Users\NHS\Downloads\MRS-main\MRS-main\MRSB.py", line 1304, in loadAccounts
    ACCOUNTS = json.load(open("accounts.json", "r"))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python311\Lib\json\__init__.py", line 293, in load
    return loads(fp.read(),
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python311\Lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python311\Lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python311\Lib\json\decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
               ^^^^^^^^^^^^^^^^^^^^^^
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 11 column 1 (char 165)

这是一个GitHub仓库,它的作者不是很响应。请让我知道你想要什么其他信息。

相关问题