简体   繁体   English

如何通过python搜索查询来获得Prolog的结果

[英]how can i get the results of Prolog by searching a query through python

This is the program which i have tried: 这是我尝试过的程序:

from pyswip import Prolog
prolog = Prolog()
prolog.assertz("father(michael,john)")
prolog.assertz("father(michael,gina)")
print  list(prolog.query("father(michael,X)"))

Output which i am getting: 我得到的输出:
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV) 进程以退出代码139结束(由信号11中断:SIGSEGV)

Expected Output: 预期产出:
X=gina X =吉娜

你应该使用

print(list(prolog.query("father(michael,X)")))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在弹性查询结果中滚动,Python - How to scroll through elastic query results, python 在Python中搜索对象列表时如何更改属性 - How can i change attribute when searching through list of objects in Python 我如何将mysql查询的结果显示到python中的Qradiobuttons中 - How can i display results from a mysql query into Qradiobuttons in python 使用数据库查询未获取任何结果时如何获得错误? - How can I get an error when no results are fetched with DB query? 如何在Python脚本中获得Perl脚本的结果? - How can I get the results of a Perl script in Python script? 当你运行 Python 时,我怎样才能得到结果? - How can I only get the results when you run Python? 如何在 MATLAB 和 Python 中获得相同的 fft2() 结果? - How can I get same results for fft2() in MATLAB and Python? 如何使用Python 3获得Google搜索结果? - How can I get Google search results with Python 3? 如何直接在 Python 中将字典键作为变量获取(而不是通过从值中搜索)? - How can I get dictionary key as variable directly in Python (not by searching from value)? 从 db 搜索名称后,如何使用 python Django 列出搜索到的名称 - After searching on a name from db how I can get the searched name listed using python Django
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM