这是我的代码:
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
它正在运作,但无论如何都要缩短它?
答案 0 :(得分:0)
O(1)
检查密钥是否存在,如果有,请更新latestId
。
latestId = None
for row in lastRow.each():
if "latest_id" in row:
latestId = row["latest_id"]