Python 获取 Object 的 Attribute
May 4, 2016
闲来无事用 Python 写了个 Twitter 的点赞 Bot,然后发现 Tweepy timeline 返回的是一个 object,那么怎么调用呢?
api = tweepy.API(auth)
postid = api.user_timeline(id = userid, count = count) //这里将 object 赋给 postid
for a in postid:
api.create_favorite(a.id_str) //这里就可以取到 id 了.
简单来说,就是 foo.fooname 这样调用.
foo = object
a = foo.attr //取 attr 的值
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.