python中的新手。在下面的代码中,我从DB
获取4610行并将它们存储在字典模式中。它提取所有行直到第二行代码和normalize()
十进制值,但是当我打印len(SDIValues)
时它只有146.它应该是4600。
#len(SDIData) = 4610rows fetched from MySQL DB
for data in SDIData:
Ibesticker =data[1].strip()
key = (data[0],Ibesticker)
if(data[3] != None):
PeriodYear = datetime.datetime.strptime(data[3], "%Y-%m-%d")
val = float(data[10].normalize())
print val #returns 4600 values
SDIValues[key] = [PeriodYear.year, val, PeriodYear.month] # something is wrong here i guess
print len(SDIValues) # 146 rows