python import xmltodict with open('data.xml') as xml_file: xml_dict = xmltodict.parse(xml_file.read()) title = xml_dict['book']['title'] author = xml_dict['book']['author'] year = xml_dict['book']['@year'] print(f"Title: {title}") print(f"Author: {author}") print(f"Year: {year}")


上一篇:
下一篇:
切换中文