這是我的代碼如何獲得tweepy api.get_user方法實體內的值(蟒蛇)
consumerKey=" "
consumerSecret=" "
accessToken=" "
accessSecret=" "
auth = tweepy.OAuthHandler(consumerKey, consumerSecret)
auth.set_access_token(accessToken,accessSecret)
api = tweepy.API(auth)
customerinfo = api.get_user('@ABC')
print "entities :",customerinfo.entities
輸出:
entities : {u'description': {u'urls': [{u'url': u'https:/t.co/fdsfdsdsff',
u'indices': [56, 79], u'expanded_url': u'http:/www.facebook.com/fsdfds',
u'display_url': u'facebook.com/dfsfds'}, {u'url': u'https:/t.co/dfdsfdsfds',
u'indices': [82, 105], u'expanded_url': u'http:/www.instagram.com/fsdfsdfds',
u'display_url': u'instagram.com/dfdsfdsfds'}]}}
我怎樣才能得到的URL值的變量? ?
我試過了customerinfo.entities.description和customerinfo.entities.urls 但它不起作用。
實體似乎是*字典*;你有沒有試過用密鑰訪問它的內容?你得到的錯誤信息究竟是什麼(*「不起作用」*很少繼續)?你有沒有讀過圖書館文檔? – jonrsharpe
我是tweepy和python的新手,可以向我發送圖書館文檔的鏈接。 –
...你是新來的谷歌搜索的東西嗎? http://www.tweepy.org/ – jonrsharpe