无效语法elif python

时间:2019-06-20 13:34:24

标签: python

运行python flask时,我得到了一个错误的无效语法elif,这是我的代码

    elif "form_jokowi" in request.form:
        elif "form_prabowo" in request.form:
            with open('crawldatauser.csv', 'r', encoding='utf-8') as f:
                reader = csv.reader(f, delimiter=',')
                tweet_result = list(reader)

                validated_tweet_positif = []
                validated_tweet_negatif = []

如果我从prabowo表格中验证错误,我该如何解决?

1 个答案:

答案 0 :(得分:1)

是否可能只需要常规的if

尝试将elif替换为if

if "form_jokowi" in request.form:
    if "form_prabowo" in request.form:
        with open('crawldatauser.csv', 'r', encoding='utf-8') as f:
            reader = csv.reader(f, delimiter=',')
            tweet_result = list(reader)

            validated_tweet_positif = []
            validated_tweet_negatif = []