我开始收到此错误,但它之前工作过,所以我不确定发生了什么变化。
文件“/var/task/lambda_function.py”,第 126 行,在 get_elevator_status 语音输出 += 'On' + 电梯 ['line'] + ' 在车站 ' + 电梯 ['车站'] + \ UnboundLocalError: 局部变量 'speech_output ' 在赋值前引用
def get_elevator_status():
session_attributes = {}
card_title = "Septa Elevator Status"
should_end_session = True
response = urllib2.urlopen(API_BASE_URL + "/elevator")
septa_elevator_status = json.load(response)
if septa_elevator_status['meta']['elevators_out'] == 0:
speech_output = 'All Elevators are currently operational'
else:
for elevators in septa_elevator_status['results']:
speech_output += 'On' + elevators['line'] + ' at station ' + elevators['station'] + \
' the ' + elevators['elevator'] + \
' elevator has ' + elevators['message'] + ' . '
return build_response(session_attributes, build_speechlet_response(
card_title, speech_output, reprompt_text, should_end_session))
汪汪一只猫
米脂
相关分类