属性错误:枚举中的值

时间:2018-05-14 16:33:51

标签: python python-3.x enums attributeerror

为什么在此代码中:

def conjugar_preterito_mais_que_perfeito_indicativo(word):
    """

    :param word: Verb to be conjugated
    :return: Conjugated verb in form of a dictionary
    """

    if not isinstance(word, str):
        return 'Entrada de dados incorreta | An incorrect input value'

    endings = ()

    if word.endswith('ar'):
        endings = enum_verbs_conjugator.TenseEndings.PRETERITO_MAIS_QUE_PERFEITO_ENDINGS_AR.value
    elif word.endswith('er'):
        endings = enum_verbs_conjugator.TenseEndings.PRETERITO_PERFEITO_ENDINGS_ER.value
    elif word.endswith('ir'):
        endings = enum_verbs_conjugator.TenseEndings.PRETERITO_MAIS_QUE_PERFEITO_ENDINGS_IR.value
    else:
        return 'A palavra não e um verbo | Not a verb'

    # is_irregular_verb = True if word in verb_persons_lists.irregular_verbs_list else False

    conjugated_forms = []
    final_conjugated_forms = dict()

    for ending in endings:
        conjugated_forms.append(word[:-2] + ending)
        conjugated_verbs_and_persons = zip(enum_verbs_conjugator.GrammaticalPersons.value, conjugated_forms)
        final_conjugated_forms = dict(conjugated_verbs_and_persons)
    return final_conjugated_forms

print(conjugar_preterito_mais_que_perfeito_indicativo('achar'))

我收到此错误:

line 137, in conjugar_preterito_mais_que_perfeito_indicativo
conjugated_verbs_and_persons = zip(enum_verbs_conjugator.GrammaticalPersons.value, conjugated_forms)
File "/usr/lib/python3.6/enum.py", line 324, in __getattr__
raise AttributeError(name) from None
AttributeError: value

我从枚举中获取元素:

看起来我的枚举没有价值。 这样对吗?我看到,Python正在指示第324行,但我没有多少行。是否无法在zip()函数中使用它的值? 我做错了什么?

0 个答案:

没有答案
相关问题