python xml.findall()返回空列表
我尽力解析xml字符串,但在搜索子元素时它返回一个空列表。我可以提供一个工作python小提琴: 但归根结底是:python xml.findall()返回空列表,python,xml-parsing,elementtree,Python,Xml Parsing,Elementtree,我尽力解析xml字符串,但在搜索子元素时它返回一个空列表。我可以提供一个工作python小提琴: 但归根结底是: root = ET.fromstring(xml_string) print(root.findall('Race')) 有什么建议吗?看起来像是新手犯的错误 root = ET.fromstring(xml_string) namespace = {'ns': 'http://ergast.com/mrd/1.4' } for race in root.find('ns:Ra
root = ET.fromstring(xml_string)
print(root.findall('Race'))
有什么建议吗?看起来像是新手犯的错误
root = ET.fromstring(xml_string)
namespace = {'ns': 'http://ergast.com/mrd/1.4' }
for race in root.find('ns:RaceTable', namespace):
round_num = race.get("round")
circuit = race.find('ns:RaceName', namespace).text
date = race.find("ns:Date", namespace).text
time = race.find("ns:Time", namespace).text
print(round_num, circuit, date, time)
错误: