Commit 0d5d0364 by lichenggang

未识别到参数或数量列先这么写着

parent 79304ec4
Showing with 15 additions and 7 deletions
......@@ -22,12 +22,17 @@ class Classify(classify_pb2_grpc.classifyServicer):
res = self.predictorfac.predict(dic_data)
res['status'] = 1
for i in ['参数', '数量']:
if i not in str(res):
if '数量' not in str(res):
res = {
'status': 0,
'err_msg': f'未识别到{i}列'
'err_msg': f'未识别到数量列'
}
if '参数' not in str(res):
res = {
'status': 0,
'err_msg': f'未识别到参数列'
}
except json.decoder.JSONDecodeError:
res = self.predictorfac.predict(request.keyword)
res['status'] = 1
......
......@@ -41,12 +41,15 @@ class DictHandler(BaseHandler):
dic_data = json.loads(self.request.body)
res = self.predictorfac.predict(dic_data)
res['status'] = 1
for i in ['参数', '数量']:
if i not in str(res):
if '数量' not in str(res):
res = {
'status': 0,
'err_msg': f'未识别到数量列'
}
if '参数' not in str(res):
res = {
'status': 0,
'err_msg': f'未识别到{i}列'
'err_msg': f'未识别到参数列'
}
except json.decoder.JSONDecodeError:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment