Can't understand why I'm getting the "raise JSONDecodeError: Expecting value" in python 3.6 Spyder IDE

Can't understand why I'm getting the "raise JSONDecodeError: Expecting value" in python 3.6 Spyder IDE

我正在按照教程在 Python 中使用深度学习创建 AI 聊天机器人(此处教程中的代码:https://www.techwithtim.net/tutorials/ai-chatbot/part-1/),但我不明白为什么我得到“ JSONDecodeError: Expecting value" 当我尝试 运行 我的代码时。 我查看了获取此信息的其他线程,但它们要么缺少答案,要么问题似乎出在用户的编码逻辑中,而不是我也可以在此处应用的通用解决方案。 我还使用 Cmd 提示符来确保我的环境 (py36) 是 运行ning python 3.6,按照教程的指示并安装了必要的库。 我希望这里有人可以帮助我吗?

错误回溯

Traceback (most recent call last):

  File "C:\Users\mecha\Documents\AI\ChatbotCode.py", line 12, in <module>
    data = json.load(file)

  File "C:\ProgramData\Anaconda3\envs\py36\lib\json\__init__.py", line 299, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)

  File "C:\ProgramData\Anaconda3\envs\py36\lib\json\__init__.py", line 354, in loads
    return _default_decoder.decode(s)

  File "C:\ProgramData\Anaconda3\envs\py36\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

  File "C:\ProgramData\Anaconda3\envs\py36\lib\json\decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None

JSONDecodeError: Expecting value

代码

import nltk
from nltk.stem.lancaster import LancasterStemmer
stemmer = LancasterStemmer()

import numpy
import tflearn
import tensorflow
import random

import json
with open('intents.json') as file:
    data = json.load(file)


words = []
labels = []
docs_x = []
docs_y = []

for intent in data['intents']:
    for pattern in intent['patterns']:
        wrds = nltk.word_tokenize(pattern)
        words.extend(wrds)
        docs_x.append(wrds)
        docs_y.append(intent["tag"])
        
    if intent['tag'] not in labels:
        labels.append(intent['tag'])

JSON 文件 (intents.json)

{"intents": [
        {"tag": "greeting",
         "patterns": ["Hi", "How are you", "Is anyone there?", "Hello", "Good day"],
         "responses": ["Hello, thanks for visiting", "Good to see you again", "Hi there, how can I help?"],
         "context_set": ""
        },
        {"tag": "goodbye",
         "patterns": ["Bye", "See you later", "Goodbye"],
         "responses": ["See you later, thanks for visiting", "Have a nice day", "Bye! Come back again soon."]
        },
        {"tag": "thanks",
         "patterns": ["Thanks", "Thank you", "That's helpful"],
         "responses": ["Happy to help!", "Any time!", "My pleasure"]
        },
        {"tag": "hours",
         "patterns": ["What hours are you open?", "What are your hours?", "When are you open?" ],
         "responses": ["We're open every day 9am-9pm", "Our hours are 9am-9pm every day"]
        },
        {"tag": "payments",
         "patterns": ["Do you take credit cards?", "Do you accept Mastercard?", "Are you cash only?" ],
         "responses": ["We accept VISA, Mastercard and AMEX", "We accept most major credit cards"]
        },
        {"tag": "opentoday",
         "patterns": ["Are you open today?", "When do you open today?", "What are your hours today?"],
         "responses": ["We're open every day from 9am-9pm", "Our hours are 9am-9pm every day"]
        }
   ]
}

问题是我的程序在更高版本中调用了 intents.json 和 data.pickle 但当然在这段代码中数据 pickle 还没有初始化所以我保留了出现空错误。