我有一个遍历列表然后加载字典的函数。它在函数中打印得很好但返回字典是空的?
95 def getAttachmentDict(messageIds):
96 messageTable = defaultdict(list)
97 for id in messageIds:
98 uri = "/message/" + id
99 res = getMessages(uri)
100 doc = xml.dom.minidom.parse(res)
101 idUrl = doc.getElementsByTagName("url")
102 alist = []
103 for i in idUrl:
104 urlData = i.childNodes[0].nodeValue
105 alist.append(urlData)
106 messageTable[id] = alist
107 print "\n"
108 for key, value in messageTable.items():
109 print "Message ID: " + key
110 print "\n".join(value)
111 return messageTable
169 getAttachmentDict(messageIds)
170 pdb.set_trace()
171 print messageTable
消息 ID:MyUHRnzm7AXkFmiKocUjzn config-safety-report.html 消息 ID:RqfljNnyz63bBpGLtL4B2D individual-report.csv
/Work/ftpTool/acquire.py(171)main() -> 打印 messageTable (Pdb) n {}