ExpatOdG,从xml获取错误:错误

2024-05-18 16:17:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我发现自己有点被下面的错误搞糊涂了

from future.standard_library import install_aliases
install_aliases()
from urllib.request import urlopen
import xmltodict

oboxml = urlopen('http://www.ebi.ac.uk/QuickGO/GTerm?id=GO:0003723&format=oboxml')
obo_dict = oboxml.read()
obo_dict_parse = xmltodict.parse(obo_dict)

返回错误:

ExpatError回溯(最近一次调用) 在里面 6 oboxml=urlopen('http://www.ebi.ac.uk/QuickGO/GTerm?id=GO:0003723&format=oboxml') 7奥博迪克特=oboxml.read() ---->;8 obo_dict_parse=xmltodict.parse(奥博迪克特)

~/anaconda3/lib/python3.6/site-packages/xmltodict.py在解析中(xml_input,encoding,expat,process_namespaces,namespace_separator,disable_entities,**kwargs) 328parser.ParseFile文件(xml_输入) 329其他: --&330吨解析器。解析(xml_输入,真) 331返回处理程序.item 332个

ExpatError:语法错误:行1,列0

正在返回xml文件,因此它不是空的。但我不知道为什么xml解析器会不高兴,尤其是我在看教程笔记本*。我使用的是xmltodict 0.11.0-py36_1,通过anaconda安装和更新。在

有什么建议吗

*以下笔记本:goatools https://link.springer.com/protocol/10.1007/978-1-4939-3743-1_16


Tags: installfromimporthttpparsewww错误xml
1条回答
网友
1楼 · 发布于 2024-05-18 16:17:12

据我所知:

Quickgo不提供xml格式。它在API中没有作为响应类型列出 https://www.ebi.ac.uk/QuickGO/api/index.html#!/annotations/downloadLookupUsingGET

我使用Bioservices包及其QuickGo工具尝试了另一种获取方法。这个包似乎已经偏离了它的文档,即曾经:

term = qgo.Term("GO:0000016", frmt="oboxml")

它不再是。术语已替换为术语,它不再接受“frmt=”或“format=”。在

我目前最接近的是:

^{pr2}$

它将返回一个列表。在

需要一个xml文件,以便与goatools包一起使用。我将编辑原来的问题,以澄清这一点,以防其他人遇到同样的问题。在

相关问题 更多 >

    热门问题