You don't need to use json
(or simplejson
, which is the exact same library; it was renamed when bundled with Python); the Twython
library already decoded everything from JSON for you.
You got a list from the API, each entry is a dict
; each such dictionary is a Tweet. You can see what is contained in the Twitter API documentation. Loop over that list; some items are dictionaries or lists themselves:
for mention in men:
print mention['user']['screen_name']
if mention['contributors']:
print [con['screen_name'] for con in mention['contributors']]
To figure out the full structure, use pprint.pprint()
to print a structured version:
import pprint
pprint.pprint(men)
which will make it easier for you to figure out what you can loop over, etc.