【问题标题】:figuring out the possible attributes of an object找出对象的可能属性
【发布时间】:2012-06-21 23:43:42
【问题描述】:

关于来自python-blogger的代码

def listposts(service, blogid):
    feed = service.Get('/feeds/' + blogid + '/posts/default')
    for post in feed.entry:
        print post.GetEditLink().href.split('/')[-1], post.title.text, "[DRAFT]" if is_draft(post) else ""

我想知道feed.entry 中存在哪些字段,但我不确定在these docs 中查找的位置。

所以我不只是想要一个答案。我想知道我应该如何浏览文档以自己找出答案。

【问题讨论】:

    标签: python gdata


    【解决方案1】:

    试试 dir(field.entry) 它可能对您的情况有用。

    【讨论】:

      【解决方案2】:

      这是一个逐步完成的案例。

      我做的第一件事是点击您发送的链接上的服务...基于service = feed.Get(...)

      这里是什么:http://gdata-python-client.googlecode.com/hg/pydocs/gdata.service.html

      然后查看 .Get() 声明

      Returns:
        If there is no ResultsTransformer specified in the call, a GDataFeed 
        or GDataEntry depending on which is sent from the server. If the 
        response is niether a feed or entry and there is no ResultsTransformer,
        return a string. If there is a ResultsTransformer, the returned value 
        will be that of the ResultsTransformer function.
      

      所以猜测你有一个 GDataFeed - 当你迭代它时:并且快速搜索“google GDataFeed”会导致:https://developers.google.com/gdata/jsdoc/1.10/google/gdata/Feed

      【讨论】:

      • 这是有道理的,但您的谷歌搜索结果是针对 javascript 类的。这似乎是正确的课程 - gdata-python-client.googlecode.com/hg/pydocs/… ...但即使有这些文档,我也不清楚如何弄清楚 .entry 做了什么。
      • 另一件事...你的意思是feed = service.Get() 不是你写的那样。
      • 一个人不时允许打嗝@thequietcenter。我同意这是糟糕的文档 - 但至少有 some 文档。另一种缩小范围的方法是做一个 type(feed) 并查看返回的类,然后对该名称进行更多的谷歌搜索,看看是否还有其他内容出现。 Python 包装器将非常接近实际界面,因此请查看 google api,看看那里的解释是否更彻底或更易于理解......
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-24
      • 1970-01-01
      • 1970-01-01
      • 2012-07-03
      • 2011-08-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多