[Python] Google vison response access changes in different system(using python)

Discussão em 'Python' iniciado por Stack, Março 9, 2025.

  1. Stack

    Stack Membro Participativo

    I am using Google vision API for text annotations, but why in some systems, the system accepts this response.full_text_annotation.pages of Google vision, and in some systems it accepts this response["fullTextAnnotation"]["pages"] of Google vision?

    Why is this so?, because of it I have to change the code again and again just to iterate over the response, in different systems.

    for page in response["fullTextAnnotation"]["pages"]:
    for block in page["blocks"]:
    for paragraph in block["paragraphs"]:
    for word in paragraph["words"]:
    print(word)

    -> but in some systems, the method it allows to iterate is

    for text in response.full_text_annotation.pages:
    for block in text.blocks:
    for para in block.paragraphs:
    for word in para.words:
    print(word)

    Continue reading...

Compartilhe esta Página