python学习之路 初识xml

时间:2022-05-29 08:08:06
import requests
from xml.etree import ElementTree as ET
r = requests.get('http://www.webxml.com.cn//webservices/qqOnlineWebService.asmx/qqCheckOnline?qqCode=577800103')
re = r.text
r1 = ET.XML(re)
print(r1.text)

简单检查qq在线

xml 之 tag  attrilb   text运用

from xml.etree import ElementTree as ET
r = ET.XML(open('1.xml','r',encoding='utf-8').read())
print(r.tag)
for rt in r:
print(rt.tag,rt.attrib,rt.find('year').text)