I am trying to use an IF loop in a FOR loop with pymongo but it doesn't work. I am using arrow library to get the hours from an epoch time and I want to run a condition on that. The problem is that my IF loop is not working and I am still getting all the results:
import arrow
for a in collection.find({}).sort("time", -1):
rawhour=arrow.get(a["time"])
hour= rawhour.format("HH")
print hour
if (hour > 15 ) :
print a
How can I make the IF loop work? Thank you!
Aucun commentaire:
Enregistrer un commentaire