mercredi 17 février 2016

invalid syntax errror in elif loop using python?

try:

    if content_type == "audio/x-wav" and len(payload):
        ref_filename = get_filename('pcm', output_filename + '_ref', LNG)
        if not os.path.exists(ref_filename):
            with open(ref_filename, 'wb') as f_pcm:
                f_pcm.write(payload)

        cur_filename = get_filename('pcm', output_filename, LNG)
        with open(cur_filename, 'wb') as f_pcm:
            f_pcm.write(payload)
    else:
        print "[ERROR] No Resposne From the Server"
        sys.exit(Error_Status)
    compare_files(ref_filename, cur_filename)
    elif content_type == "application/json":
        with open(get_filename('json', output_filename, LNG), 'w') asf_json:
            f_json.write(payload)
except:
    print "\n[ERROR] Can't Create Reference PCM or Response JSON files!"
    Error_Status = 1

I am trying to print Error message if the IF loop in my above code does not execute. so I am using if loop then later else loop to print the error message. later I am comparing the files. then I am doing elif statement. I am doing all those things within try and except block. But I am getting the error as

elif content_type == "application/json":
   ^
SyntaxError: invalid syntax

Aucun commentaire:

Enregistrer un commentaire