0
f = open('transaction.log','r')
ClerkHash = dict()
arr = [0,0]
for line in f:
Tdate = line[0:12]
AccountKey = line[12:50]
TransType = line[22:2]
ClerkKey = line[24:10]
CurrencyCode = line[34:2]
Amount = line[36:45]
print line
print '\n'
print AccountKey
print '\n'
print Tdate print '\n'
if TransType=="04":
ClerkHash[ClerkKey+AccountKey] = arr; // is this line corrent ? i don't want to corrupt the array every time ? how should i do it ?
ClerkHash[ClerkKey+AccountKey][0]+=1
ClerkHash[ClerkKey+AccountKey][1]+= Amount
for Key in ClerkHash.keys():
if ClerkHash[key][0] >= 3 and ClerkHash[key][1] > 1000:
print Key
我想有一個哈希名稱ClerkHash [ClerkKey + AccountKey] 其中2 INT的陣列的consistes:第一索引是戒斷NUM,並且第二個是ammount的 做我定義了數組和哈希好? 另外我想總結ammount ...我該怎麼做呢?蟒 - 問題INT /串和散列/陣列
,你不應該做的'打印AccountKey'(而不是僅僅'AccountKey') –
這將真正如果您指定的預期輸出會是什麼幫助。而是會發生什麼呢。 – Skurmedel
行[22:2]不會返回任何內容,因爲切片的結束在開始之前。 – nosklo