打印 python 中的列表项

Print list item in python

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

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

结果是一个列表:

[{'translation_text': '“Excellent”. Cleanliness and helpful staff.'}]

我只想要这部分'“优秀”。清洁和乐于助人的员工。' 待打印。

我该怎么做?

您可以索引列表和字典——使用 [0] 访问第一个元素,使用 ['translation_text']:

访问字典的唯一值
translated = pipe(reviews['review'][0])[0]['translation_text']