首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在PyClips中显示变量的值

在PyClips中显示变量的值
EN

Stack Overflow用户
提问于 2014-10-27 20:57:42
回答 1查看 239关注 0票数 0

--我一直在尝试在PyClips中打印变量的值,而没有任何success.Any帮助,我们将不胜感激。这是代码.

,而不是“你能观察”,是吗?命名为“

代码语言:javascript
复制
def clips_raw_input(prompt):
    return clips.String(raw_input(prompt))

clips.RegisterPythonFunction(clips_raw_input, "input")


clips.Assert("(quality observative) ")
clips.Assert("(quality communicative) ")
clips.Assert("(quality emotionally-stable) ")
clips.Assert("(has human true)")

r1 = clips.BuildRule(
       "what-are-qualities",
       """(quality ?name)
       (not (has ?name ?))""",
        """(bind ?response (python-call input Are you ?name))
       (assert (has ?name ?response))""")

任何帮助都将不胜感激,

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-11-02 16:00:57

代码语言:javascript
复制
>>> import clips
>>> def clips_raw_input(prompt):
...         return clips.String(raw_input(prompt))
... 
>>> clips.RegisterPythonFunction(clips_raw_input, "input")
>>> r1 = clips.BuildRule(
...        "what-are-qualities",
...        """(quality ?name)
...        (not (has ?name ?))""",
...        """(bind ?response (python-call input (str-cat "Are you " ?name "? ")))
...        (assert (has ?name ?response))""")
>>> clips.Reset()
>>> clips.Assert("(quality observative) ")
<Fact 'f-1': fact object at 0x10450b330>
>>> clips.Assert("(quality communicative) ")
<Fact 'f-2': fact object at 0x10450b360>
>>> clips.Assert("(quality emotionally-stable) ")
<Fact 'f-3': fact object at 0x10450b3f0>
>>> clips.Assert("(has human true)")
<Fact 'f-4': fact object at 0x10450b450>
>>> clips.Run()
Are you emotionally-stable? yes
Are you communicative? no
Are you observative? yes
3
>>> clips.PrintFacts()
f-0     (initial-fact)
f-1     (quality observative)
f-2     (quality communicative)
f-3     (quality emotionally-stable)
f-4     (has human true)
f-5     (has emotionally-stable "yes")
f-6     (has communicative "no")
f-7     (has observative "yes")
For a total of 8 facts.
>>> 
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26596710

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档