我正在尝试检查 GQL 对象是否为空(在使用 Python 的 Google App Engine 中),我应该怎么做?我试过了,但没有用:
comments = db.GqlQuery("SELECT * "
"FROM Comment "
"where ANCESTOR IS :1 "
"order by date DESC",
movie_data)
if comments:
ratingsum = 0
i=0
for comment in comments:
ratingsum=ratingsum + comment.rating
i+=1
average = ratingsum/i
else:
average = "no ratings"