BeautifulSoup does not parse xml with other encoding than utf-8

前端 未结 2 689
花落未央
花落未央 2021-01-19 18:14

I can read all xmls files that starts with but I can not read the files starts with

2条回答
  •  独厮守ぢ
    2021-01-19 18:51

    Coincidentally I stumbled upon another workaround. Read the file in binary mode ('rb'):

    with open('tests/xml-iso.xml', 'rb') as f_in:
        xml_soup = Soup(f_in.read(), 'xml')
    

提交回复
热议问题