我存储的格式为:
网页/网站/ objecthash / xcord / ycord /情形产生/年/月/ datenumber /小时/分钟
现在我有了我想把它们拉出来的水桶。
说我想要最近的10个存储对象。有效的方法是什么?
我有水桶,我该怎么办?
我今天的解决方案是这样的,但是我不确定最近获得的逻辑:
def getKeys():
b = bucket.list()
theKeys=[]
for key in b:
theKeys.append(key)
return theKeys
def getDecompiledToday():
time = datetime.datetime.now()
year =time.strftime("%Y")
month = time.strftime("%m")
day = time.strftime("%D")
keys = getKeys()
objects = []
for k in keys:
splitK= k.split("/")
if splitK[6]==year and splitK[7]==month and splitK[8]==day:
objets.append(bucket.get_key(k))
return
答案 0 :(得分:0)
我提出的解决方案。
def getPastAmountDecompiledFromFile(number):
if bucketKeys.__len__() > 0:
Found=[]
latest=bucketKeys[0]
while Found.__len__() < number:
laterFound = False
for k in bucketKeys:
if latest in Found:
latest=k
current = k.split("/")
best = k.split("/")
if k not in Found and latest != k:
if int(current[6]) > int(best[6]):
laterFound=True
if int(current[6]) == int(best[6]) and int(current[7]) > int(best[7]):
laterFound=True
if int(current[6]) == int(best[6]) and int(current[7]) == int(best[7]) and int(current[8]) > int(best[8]):
laterFound=True
if int(current[6]) == int(best[6]) and int(current[7]) == int(best[7]) and int(current[8]) == int(best[8]) and int(current[9]) > int(best[9]):
laterFound=True
if laterFound:
latest = k
if laterFound:
Found.append(latest)
return getKeyFromKeyNames(Found)
else:
getKeysInFile()
getPastAmountDecompiledFromFile(number)
return