शुरू करेंमुफ़्त में शुरू करें

Loading and accessing tweets

In the video, we loaded a tweet we collected using tweepy into Python. Tweets arrive from the Streaming API in JSON format and need to be converted into a Python data structure.

In this exercise, we'll load a single tweet into Python and print out some fields.

The tweet JSON has been loaded for you and is stored in tweet_json.

यह अभ्यास पाठ्यक्रम का हिस्सा है

Analyzing Social Media Data in Python

पाठ्यक्रम देखें

अभ्यास निर्देश

  • Import the json module.
  • Convert the tweet JSON stored in tweet_json from JSON to Python object using json's .loads() method.
  • Print the tweet text and id using the appropriate keys.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Load JSON
import ____

# Convert from JSON to Python object
tweet = ____.____(tweet_json)

# Print tweet text
print(tweet[____])

# Print tweet id
print(tweet[____])
कोड संपादित करें और चलाएँ