python - XML/KML 格式不正确
问题描述
我正在尝试使用以下内容解析 KML 服务:
import requests
import responses
import xml.etree.ElementTree as ET
response = requests.get('http://206.74.144.42/eitms/roadconditions/')
data = str(response.content)
tree = ET.fromstring(data)
但它一直告诉我 XML 格式不正确,如下所示:
not well-formed (invalid token): line 1, column 1
这是什么意思,我该如何解决?使用 Python 3.6。
解决方案
直接调用fromstring(response.content)
,不使用str()
.
推荐阅读
- android - 即使在 android webview 中加载网站后,进度条也不会停止
- python - 我们可以创建一个不满足用于创建对象的类吗?
- java - 多项式程序未按预期工作
- python-3.x - 无法使用我的烧瓶应用程序在远程服务器(Heroku)上上传图像
- python - 如何在没有 pb 文件的情况下将 tflite 模型转换为量化模型
- google-apps-script - 删除 NamedRange 的文本会在该行留下一个空段落
- sql-server - SQL Server 触发器:限制记录插入
- windows - PSQL 总是返回角色不存在,如何解决?
- java - 使用 Java Kubernetes 客户端 Api 部署 pod
- video - 带 B 帧的 mp4 文件是否需要 CTTS 盒?