我有一个包含超过 100 万个字符的单元格的 kml 文件。我想将小数位数从 12 减少到 3。我导入了 lxml 和 pykml。
import pykml
from pykml.helpers import set_max_decimal_places
file1=open('\United States divisions. Level 2.kml')
from os import path
#set_max_decimal_places(file1, max_decimals={'longitude':3,'latitude':3,})
我得到了这个错误:
39 index_no = 0 # longitude is in the first position
40 # modify <longitude>
---> 41 for el in doc.findall(".//{http://www.opengis.net/kml/2.2}longitude"):
42 new_val = round(float(el.text), max_decimals[data_type])
43 el.getparent().longitude = K.longitude(new_val)
AttributeError:“文件”对象没有属性“findall”