Py学习  »  Python

用python打印列表项

stu_dent • 3 年前 • 1282 次点击  

我使用python中的管道,使用以下指令将评论翻译成英语

translated = pipe(reviews['review'][0])

结果是一个列表:

[{'translation_text':'非常好。整洁,员工乐于助人。}]

我只想要这一部分 “太好了。清洁和乐于助人的员工。” 待打印。

我该怎么做?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/132618
 
1282 次点击  
文章 [ 1 ]  |  最新文章 3 年前
BrokenBenchmark
Reply   •   1 楼
BrokenBenchmark    3 年前

您可以索引到列表和字典中——使用 [0] ,并使用 ['translation_text'] :

translated = pipe(reviews['review'][0])[0]['translation_text']