[Python] I got the translation from googletrans working in Python but want to pull just the...

Discussão em 'Python' iniciado por Stack, Novembro 20, 2024.

  1. Stack

    Stack Membro Participativo

    so I got a basic CLI python translator to function, now I need help pulling just the translated text from the result.

    This is my current code


    from googletrans import Translator

    # Taking input for language to be translated
    translate_from = input("What language would you like to translate from? ")
    translate_to = input("What language would you like to translate to? ")

    # Taking input for text to be translated
    translate_text = input("Please enter your text to be translated ... ")

    # translate languages
    translator=Translator()

    print("Translation > ", translator.translate(translate_text, src=translate_from, dest=translate_to))

    This is the current output:


    Translation > Translated(src=en, dest=es, text=Hola, pronunciation=None, extra_data="{'translat...")
    ​

    I would like it to just pull the text only instead of the above. Can anyone help me on this because I am pretty stumped!

    Also I am very new to Python, so please go easy on me!

    Continue reading...

Compartilhe esta Página