开发者社区 问答 正文

期望值:第1行第1列(char 0)

我试着把NAO机器人和Node-Red连接起来。 当我运行这段代码与Node-Red通信时,

class MyClass(GeneratedClass):
    def __init__(self):
        GeneratedClass.__init__(self)

    def onLoad(self):
        #put initialization code here
        pass

    def onUnload(self):
        #put clean-up code here
        import sys
        #if self.WatsonImageFolderName and WatsonImageFolderName in sys.path:
        #    sys.path.remove(WatsonImageFolderName)

    def onInput_onStart(self, p):
        #self.onStopped() #activate the output of the box
        chat_context = ("x")
        self.log(chat_context)
        import sys, os, json, base64
        import requests
        tts = ALProxy('ALTextToSpeech')
        url = ('###URL###')
        payload = {
          "msgdata": p
        }

        payload['context'] = chat_context
        self.log(payload)
        r = requests.post(url, data=payload)
        response = r.json()
        if response['botresponse']:
            self.log(response['botresponse'])
            self.log(response['botresponse']['messageout']['output']['text'])
            chat_context = response['botresponse']['messageout']['context']
            self.log(chat_context)
            self.log(chat_context['system'])
            tts.say(str(response['botresponse']['messageout']['output']['text'][0]))
    def onInput_onStop(self):
        self.onUnload() #it is recommended to reuse the clean-up as the box is stopped
        self.onStopped() #activate the output of the box

但是,当我执行这段代码时,它会导致以下错误 谁能告诉我为什么会出现这个错误? 问题来源StackOverflow 地址:/questions/59387106/python-jsondecodeerror-expecting-value-line-1-column-1-char-0

展开
收起
kun坤 2019-12-25 21:44:21 379 分享 版权
0 条回答
写回答
取消 提交回答
问答分类:
问答地址: