使用 goslate 进行 Python 翻译

问题描述

我正在构建一个翻译器,使用 python 将用户输入翻译成法语。然而,我遇到了一个挑战,我的 goslate 函数无法捕获用户输入并进行翻译。我将感谢您的帮助。

import goslate
gs = goslate.Goslate()

text = input("please input the word you would like translated:\n")
gs.translate(text,'fr')

解决方法

您必须打印输出或将其保存到变量中。例如

import goslate
gs = goslate.Goslate()
text = input("please input the word you would like translated:\n")
print(gs.translate(text,'fr'))

输出:

please input the word you would like translated:
Hello
Bonjour

查看the documentation了解更多详情。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...