[問題] 請教elementtree的問題
大家好!我是一位python的新手
目前使用ElementTree遇到了一些問題
想請教各位解決的方法
目標:嘗試自己爬出想要的資料
檔案格式:xml,http://imgur.com/rxp5q7A

問題:使用ElementTree爬資料時,印不出tag中的值,一直印出空的dictionary
程式碼:
import xml.etree.ElementTree as ET
import xml.etree.cElementTree as ET
tree = ET.parse('councillors.xml')
root = tree.getroot()
for child in root:
for gchild in child:
print gchild.attrib
謝謝各位幫我解答^^
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.117.247.80
※ 文章網址: http://www.ptt.cc/bbs/Python/M.1420007349.A.B5E.html
推
12/31 17:24, , 1F
12/31 17:24, 1F
→
12/31 17:25, , 2F
12/31 17:25, 2F
→
01/02 00:55, , 3F
01/02 00:55, 3F
Python 近期熱門文章
PTT數位生活區 即時熱門文章