트윗은 파이썬 사전 일 뿐이며 내용은 정확히 Tweet
resource입니다. 각각의 트윗은, 따라서 id_str
키가 있습니다 일이 명확하지 않은 경우 당신은 항상 데이터 구조를 인쇄 할 수 있습니다
print tweet['id_str']
을; 나는 여분의 읽을 중첩 된 파이썬 구조를 만들기 위해 pprint.pprint()
function을 추천 할 수 있습니다 :
import pprint
pprint.pprint(tweet)
예 세션 :
>>> from twython import Twython
>>> t = Twython()
>>> res = t.search(q='python')
>>> res.keys()
[u'next_page', u'completed_in', u'max_id_str', u'since_id_str', u'refresh_url', u'results', u'since_id', u'results_per_page', u'query', u'max_id', u'page']
>>> from pprint import pprint
>>> pprint(res[u'results'][0])
{u'created_at': u'Mon, 17 Sep 2012 21:01:12 +0000',
u'from_user': u'Me_Craay_GOOFY',
u'from_user_id': 230100184,
u'from_user_id_str': u'230100184',
u'from_user_name': u'\u06deSuperFLY_PUER\u06de\u2122',
u'geo': None,
u'id': 247802407529115649,
u'id_str': u'247802407529115649',
u'iso_language_code': u'en',
u'metadata': {u'result_type': u'recent'},
u'profile_image_url': u'http://a0.twimg.com/profile_images/2617747450/345616051_normal.jpg',
u'profile_image_url_https': u'https://si0.twimg.com/profile_images/2617747450/345616051_normal.jpg',
u'source': u'<a href="http://globalgrind.com">UncleUber for Blackberry</a>',
u'text': u'RT @Mr_Oyato: #ViolentPrayers May the python of breakthrough swallow you and your household today.',
u'to_user': None,
u'to_user_id': 0,
u'to_user_id_str': u'0',
u'to_user_name': None}
>>> res[u'results'][0]['id_str']
u'247802407529115649'