RDF库和SPARQL ISU

2024-09-26 18:20:08 发布

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

在我的python文件中,我导入了rdflib并实现了一些SPARQL查询来进行一些测试。这是我现在的密码。你知道吗

from rdflib import Graph

if __name__ == '__main__':
    g = Graph()

    g.parse('http://localhost:8085/weather-2.html', format='rdfa')

res1 = g.parse('http://localhost:8085/weather-2.html', format='rdfa')
print(res1.serialize(format='pretty-xml').decode("utf-8"))
print()

res2 = g.query("""SELECT ?obj
    WHERE { <http://localhost:8085/weather-2.html> weather:region obj . }
    """)
for row in res2:
    print(row)

我运行了我的代码,得到了这个错误。你知道吗

ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

urllib.error.URLError: <urlopen error [WinError 10061] No connection could be made because the target machine actively refused it>

这是因为我的文件weather-2.html的目录吗?你知道吗

或者这是我的记忆中缺少的东西?你知道吗

我使用pycharm作为我的编辑器,是的,我记得安装了所有的软件包,所以我不确定是什么导致了这个错误。你知道吗


Tags: 文件theobjformatlocalhosthttpparsehtml

热门问题