微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何访问 tweet 对象的 expand_url?

如何解决如何访问 tweet 对象的 expand_url?

基于用于网址的 Twitter API:https://developer.twitter.com/en/docs/twitter-api/v1/data-dictionary/object-model/entities#urls

我想从推文的 'entities' 属性的 'url' 属性获取 'expanded_url' 属性。现在我有这个代码

if post["entities"]["urls"]:
    url = post["entities"]["urls"]
        print(url)

以这种格式打印数组:

[{'display_url': 'xxx','indices': [xx,xx],'expanded_url': 'xxx','url': 'xxx'}]

我想获得“expanded_url”,并尝试了 url["expanded_url"],它只是抛出了一个错误

TypeError: list indices must be integers or slices,not str

有谁知道如何检索 url 属性的子属性

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。