问题描述
基于用于网址的 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
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)