我想檢查是否有GQL對象是否爲空(在使用Python谷歌應用程序引擎),我應該怎麼辦呢? 我試過,但沒有奏效:如何檢查是否GQL對象爲空
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"