我正在尝试使用python-instagram执行标记搜索并返回位置。
我收到错误: AttributeError:'list'对象没有属性'location'
以下是我的尝试:
services.AddTransient<IUnitOfWork, UnitOfWork>();
我确信在执行以下测试后我正在解析一些位置对象...
from instagram.client import InstagramAPI
client_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
access_token="xxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
api = InstagramAPI(client_id=client_id, client_secret=client_secret,access_token=access_token)
tag = 'wtcampus'
search= api.tag_recent_media(tag_name=tag)
if ['location'] is not None:
for media in search:
print media.location.point.latitude
print media.location.point.longitude
返回2.如何返回lat和long这些对象?
答案 0 :(得分:0)
if ['location'] is not None:
for media in search:
print media.location.point.latitude
print media.location.point.longitude
此if
语句将始终执行。我没有使用Instagram API,但相信这应该有效:
if search['location']:
for media in search:
print media.location.point.latitude
print media.location.point.longitude
将来,if x is not None
可以简单地写为if not x
。