在 rdflib.store.IOMemory 中添加三元组时出现问题
每当我尝试使用以下代码将三元组添加到商店中时,都会出现以下错误。您能在这方面帮助我吗?提前致谢。
store = plugin.get('IOMemory',Store)()
store.add((abc, FOAF['knows'],def))
Error:
Traceback (most recent call last):
File "C:\Python27\internetcode.py", line 114, in <module>
store.add((abc, FOAF['knows'],def))
TypeError: add() takes at least 3 arguments (2 given)
Whenever I try to add triple into the store using following code it gives me following error. Could you please help me in this regard. Thanks in advance.
store = plugin.get('IOMemory',Store)()
store.add((abc, FOAF['knows'],def))
Error:
Traceback (most recent call last):
File "C:\Python27\internetcode.py", line 114, in <module>
store.add((abc, FOAF['knows'],def))
TypeError: add() takes at least 3 arguments (2 given)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来你必须传递至少 3 个参数。在 文档在该模块中,您可以看到哪些参数需要
add
方法:(abc, FOAF['knows'],def)
是您的三元组吗?在这种情况下,您还需要两个:context
和quoted
我找到了更多信息 此处
It seems you have to pass at least 3 arguments. In the documentation of that module you can see what arguments needs
add
method:(abc, FOAF['knows'],def)
is your triple? in that case you need two more:context
andquoted
I've found some more information here
首先,你需要知道,当 python 说一个方法需要 3 个参数时,它实际上意味着两个参数加上实例参数(通常是
self
)。您当前正在传递实例 (store
) 以及一个三元素元组:(abc, FOAF['knows'], def)
,它算作一个参数。 store.add() 需要第三个参数。这就是错误消息试图告诉您的内容。我不知道它需要什么,但文档应该能够进一步解释。如果没有别的事,您可以尝试 store.add((abc, FOAF['knows'], def), None),看看是否会导致新的错误。
So first, you need to know that when python says that a method takes 3 arguments, it really means two argument plus the instance argument (usually
self
). You are currently passing the instance (store
) plus a three element tuple:(abc, FOAF['knows'], def)
, which counts as one argument.store.add()
needs a third argument. That's what the error message is trying to tell you. I don't know what it needs, but the documentation should be able to explain further.If nothing else, you can try
store.add((abc, FOAF['knows'], def), None)
, and see if that causes a new error.