我想在應用程序中編寫一小段代碼來檢查用戶是否關注您。我只想讓代碼返回一個True/False值,我可以把它放在一個if循環中。從JSON Twitter響應(Tweepy和Python)中提取單個True/False值
的代碼是:
user_id = '1234567890'
print api.show_friendship(target_id=user_id)
,並返回這一切的JSON,我一無所知,但想從下「下」(或者其他用戶的第二陣列的「假」值,真/假,從下「followed_by」第一陣列......無論哪種方式是好的)!
{"relationship":{"source":{"id":0000000000,"id_str":"0000000000","screen_name":"auth_user","following":false,"followed_by":false,"following_received":false,"following_requested":false,"notifications_enabled":false,"can_dm":false,"blocking":false,"blocked_by":false,"muting":false,"want_retweets":false,"all_replies":false,"marked_spam":false},"target":{"id":123456789,"id_str":"123456789","screen_name":"other_user","following":false,"followed_by":false,"following_received":false,"following_requested":false}}}
我怎樣才能讓我的代碼返回真/假的「以下」:假的一部分?
(或中,「followed_by」:第一陣列中假部分 - 每一個陣列是從用戶的關係的「視點」)