【发布时间】:2021-04-10 20:59:12
【问题描述】:
通过python使用gcloud translate的codelab example只翻译一个字符串:
sample_text = "Hello world!"
target_language_code = "tr"
response = client.translate_text(
contents=[sample_text],
target_language_code=target_language_code,
parent=parent,
)
for translation in response.translations:
print(translation.translated_text)
但由于它将 sample_text 放在一个列表中并迭代响应,我认为它可以提交更长的列表。这是真的吗?我可以指望响应中与内容中的项目顺序相对应的项目吗?一定是这样,但我在文档中找不到明确的答案。
【问题讨论】:
标签: python-3.x gcloud google-translate