Keep it
Can test files with chardetect.
uft-8
all the way,make sure editor don't mess it when save stuff.Can test files with chardetect.
G:\div_code\answer λ chardetect pla.kml pla.kml: utf-8 with confidence 0.99Example:
from bs4 import BeautifulSoup """ <?xml version="1.0" encoding="utf-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <Placemark> Μῆνιν ἄειδε </Placemark> <Placemark> 異體字字 </Placemark> </Document> </kml> """ soup = BeautifulSoup(open('pla.kml', encoding='utf-8'), 'xml') mark = soup.find_all('Placemark') print(mark) with open('pla_out.kml', "w", encoding='utf-8') as fp: fp.write(soup.prettify(formatter=None))
Output:[<Placemark>Μῆνιν ἄειδε</Placemark>, <Placemark>異體字字</Placemark>]
pla_out.kml
Output:<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
Μῆνιν ἄειδε
</Placemark>
<Placemark>
異體字字
</Placemark>
</Document>
</kml>