我正在从数据库中提取数据,并尝试使用python请求通过API将其传递给我的网络应用。我已经做过几次了,但是在这个脚本上我很难受。
它给我“ ValueError:没有足够的值要解压(预期2,得到1)”
bot.py run
你们能给我的任何线索将不胜感激。
编辑:
根据要求进行跟踪。...
Bot loaded. Type a message and press enter:
'Hello'
XXX lineno: 105, opcode: 0
Traceback (most recent call last):
File "bot.py", line 90, in <module>
run()
File "bot.py", line 68, in run
agent.handle_channel(ConsoleInputChannel())
File "C:\Users\Vincent\Documents\Chatbot_Eleven_Candidats\Versions\rasa_test4\rasa_core\agent.py", line 123, in handle_channel
processor.handle_channel(input_channel)
File "C:\Users\Vincent\Documents\Chatbot_Eleven_Candidats\Versions\rasa_test4\rasa_core\processor.py", line 60, in handle_channel
input_channel.start_sync_listening(self.handle_message)
File "C:\Users\Vincent\Documents\Chatbot_Eleven_Candidats\Versions\rasa_test4\rasa_core\channels\console.py", line 52, in start_sync_listening
self._record_messages(message_handler)
File "C:\Users\Vincent\Documents\Chatbot_Eleven_Candidats\Versions\rasa_test4\rasa_core\channels\console.py", line 45, in _record_messages
self.sender_id))
File "C:\Users\Vincent\Documents\Chatbot_Eleven_Candidats\Versions\rasa_test4\rasa_core\processor.py", line 81, in handle_message
self._handle_message_with_tracker(message, tracker)
File "C:\Users\Vincent\Documents\Chatbot_Eleven_Candidats\Versions\rasa_test4\rasa_core\processor.py", line 221, in _handle_message_with_tracker
parse_data = self._parse_message(message)
File "C:\Users\Vincent\Documents\Chatbot_Eleven_Candidats\Versions\rasa_test4\rasa_core\processor.py", line 210, in _parse_message
parse_data = self.interpreter.parse(message.text)
File "C:\Users\Vincent\Documents\Chatbot_Eleven_Candidats\Versions\rasa_test4\rasa_core\interpreter.py", line 236, in parse
return self.interpreter.parse(text)
File "C:\Users\Vincent\Documents\Chatbot_Eleven_Candidats\Versions\rasa_test4\rasa_nlu\model.py", line 344, in parse
component.process(message, **self.context)
File "C:\Users\Vincent\Documents\Chatbot_Eleven_Candidats\Versions\rasa_test4\rasa_nlu\featurizers\count_vectors_featurizer.py", line 149, in process
bag = self.vect.transform([self._lemmatize(message)]).toarray()
File "C:\Users\Vincent\Anaconda3\lib\site-packages\sklearn\feature_extraction\text.py", line 923, in transform
_, X = self._count_vocab(raw_documents, fixed_vocab=True)
File "C:\Users\Vincent\Anaconda3\lib\site-packages\sklearn\feature_extraction\text.py", line 792, in _count_vocab
for feature in analyze(doc):
File "C:\Users\Vincent\Anaconda3\lib\site-packages\sklearn\feature_extraction\text.py", line 266, in <lambda>
tokenize(preprocess(self.decode(doc))), stop_words)
File "/usr/local/lib/python3.5/dist-packages/rasa_nlu/featurizers/count_vectors_featurizer.py", line 105, in <lambda>
SystemError: unknown opcode
ValueError:没有足够的值可解包(预期2,得到1)
编辑答案:
API需要一个字符串,而不是我正在传递的列表。只需将API调用更改为data = str(dictofdata)。谢谢您的帮助。
答案 0 :(得分:0)
API期望使用字符串而不是我尝试传递的列表。
更改此...
响应= requests.put(api_request_url,headers = headers,data = dictofdata)
对此...
response = requests.put(api_request_url,headers = headers,data = str(dictofdata))
现在可以正常工作。谢谢大家。