shell pip install xmltodict python import xmltodict xml_data = '''<book> <author>John Smith</author> <pages>300</pages> </book>''' data_dict = xmltodict.parse(xml_data) title = data_dict['book']['title'] print('Title:', title) author = data_dict['book']['author'] print('Author:', author) pages = data_dict['book']['pages'] print('Pages:', pages) Author: John Smith Pages: 300


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