XML Unicode strings with encoding declaration are not supported

前端 未结 3 1300
醉酒成梦
醉酒成梦 2020-12-09 02:50

Trying to do the following...

from lxml import etree
from lxml.etree import fromstring

if request.POST:
    parser = etree.XMLParser(ns_clean=True, recover=         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-09 03:43

    More simple than answers above:

    from lxml import etree
    
    #Do request for data, response = r#
    data = etree.fromstring(bytes(r.text, encoding='utf-8'))
    

提交回复
热议问题