开始使用免费开始使用

访问转推数据

现在我们将处理一个包含转推的推文 JSON。转推与普通推文的结构相同,但会在 retweeted_status 中再存储一条推文。

新的推文对象已加载为 rt

本练习是课程的一部分

在 Python 中分析社交媒体数据

查看课程

练习说明

  • 打印该推文的文本。
  • 打印被转推的那条推文的文本,保存在 retweeted_status 中。
  • 打印该推文的用户账号(handle)。
  • 打印被转推的那条推文的用户账号(handle),保存在 retweeted_status 中。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Print the text of the tweet
print(rt[____])

# Print the text of tweet which has been retweeted
print(rt[____][____])

# Print the user handle of the tweet
print(rt[____][____])

# Print the user handle of the tweet which has been retweeted
print(rt[____][____][____])
编辑并运行代码