我有文件名列表通過processTestFile()函數,返回結果的字典,我想存儲運行:如何在for循環中組織函數結果?
# Count success or failure of test cases
counts = {
"success": 0,
"failure": 0
}
主要工藝循環如下所示:
for fileName in all_files(fileReferences["testCasesPath"],"*.txt") :
print "\n\nRunning test case file = ", fileName
myCounts = processTestFile(fileName)
我想的是一樣的東西:
myArray = {}
myArray[fileName] = myCounts
,我會作爲參考:
for name in myArray
print name, myArray[name] ["success"], myArray[name] ["failure"]
我懷疑這個代碼會起作用。你有什麼建議?
什麼是真正的問題? – Kugel
爲什麼你懷疑它會起作用?它失敗了嗎?什麼是錯誤? – jdi
請閱讀[PEP 8 - Python代碼風格指南](http://www.python.org/dev/peps/pep-0008/)! – astynax