0
我原本我的計劃,像這樣:Python的詞典列表
inst = {}
class IContainer:
dicList = {}
for i in range(10):
inst[i] = IContainer()
def FindEnd(node):
if node.text != None:
inst[counter].dicList[node.tag] = node.text
else:
for subNode in node:
FindEnd(subNode)
counter = 0
for element in root:
if element.tag == "Items":
for subE in element:
if subE.tag == "Item":
for subSubE in subE:
FindEnd(subSubE, counter)
counter += 1
的作品就好了,我是能夠解析的東西變成一本字典,我要創建列表,而不是動態的。
所以
counter = 0
for element in root:
if element.tag == "Items":
for subE in element:
if subE.tag == "Item":
inst[counter] = IContainer()
for subSubE in subE:
FindEnd(subSubE)
for i in range(len(inst)):
print inst[i]
print inst[i].dicList
counter += 1
當我運行與最終環的地址和數據被替換此
for i in range(len(inst)):
print inst[i]
print inst[i].dicList
所有研究所....我沒有帶一個線索什麼錯。