【发布时间】:2018-01-16 04:17:19
【问题描述】:
这是我的代码:
lastRow = db.child("twitter-search").order_by_key().limit_to_last(1).get(user['idToken'])
latestId = None
for row in lastRow.each():
for key, value in row.val().items():
if key == "latest_id":
latestId = value
它正在工作,但有没有办法让它更短?
【问题讨论】:
-
您可以指定为: latestId = row.val()["latest_id"] 而不是每次都遍历行
标签: python loops dictionary iteration