2

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

import goslate
gs = goslate.Goslate()

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

1 回答 1

1

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

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

查看文档以获取更多详细信息。

于 2021-03-06T14:02:36.400 回答