【发布时间】:2018-09-12 15:02:37
【问题描述】:
我正在以下脚本中用 python 分析 AWS 响应:
#var definition
conversationName = 'NO NAME'
#in the MyClass
if len(resp['FaceMatches'])>0:
faceRecognized = resp['FaceMatches'][0]['Face']['ExternalImageId']
self.logger.info(str(faceRecognized))
if resp['FaceMatches'][0]['Face']['ExternalImageId'] == self.conversationName:
self.logger.info("Name is the same")
return
else:
self.logger.info('Name has changed!')
self.conversationName=faceRecognized.split('_')[0]
self.pepperTTS.say("Hi "+str(faceRecognized.split('_')[0])+". Can I help you with something?")
return
else:
self.logger.info("No face rekognized so far.")
return
问题在于第二个 IF ELSE。当我运行程序时,它似乎完全忽略了这个 IF ELSE 并且既不打印“名称相同”也不打印“名称已更改”。并且在运行脚本时不会显示任何错误。
有没有人看到错误或者可以提供一些提示来纠正脚本?
【问题讨论】:
-
脚本是否打印“到目前为止没有人脸识别。”?如果
if len(resp['FaceMatches']) > 0评估为false,那么您的内部if-else将不会被评估并且您不会打印您提到的任何一个值。