我有一个文件名列表要通过processTestFile()函数运行,该函数返回我想要存储的结果字典:
# 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"]
我怀疑这段代码是否有用。你有什么建议吗?
答案 0 :(得分:1)
myArray
是dict
的奇怪名称。确保将外部循环
myArray = {}
for fileName in all_files(fileReferences["testCasesPath"], "*.txt"):
print "\n\nRunning test case file = ", fileName
myCounts = processTestFile(fileName)
myArray[fileName] = myCounts
for name, value in myArray.items()
print name, value["success"], value["failure"]