从 GDataEntry 中提取 ID 字符串
我正在 python 中使用 Google 的 gdata API。更具体地说,我正在使用 YouTube API,但我不认为它与这个问题相关。
我现在有一个对象,它是 GDataEntry 的子类,我正在尝试获取它的 id。
print entry.id
这会失败,因为它无法将 Id 对象转换为字符串。所以我尝试:
print str(entry.id)
将其序列化为 XML 字符串。我真正想要的是ID的文本内容。我一直在查看文档,但到目前为止我还找不到它。我相信这确实很容易做到,但我找不到正确的方法来获取 Id 对象的文本内容。
I am playing around with Google's gdata API in python. More specificalyl, I am using the YouTube API, but I do not believe it will be relevant to this question.
I now have an object which is a subclass of GDataEntry and I am trying to get its id.
print entry.id
this fails as it cannot convert and Id object to a string. So I try:
print str(entry.id)
which serializes it to an XML string. What I really want is the textual content of the ID. I have been looking through the docs, and I was unable to find it so far. I am convinced this is really easy to do, but I cannot find the right method to get the text content of the Id object.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我很确定,
entry.id
的类型为atom.Id
,它提供了ToString
方法和text< /code> 访问器。请参阅此处的文档。
所以你想写:
I'm pretty sure, that
entry.id
is of the typeatom.Id
which provides aToString
method and atext
accessor. See the documentation here.So you'd like to write: