我试着把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
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。