在Python中调用Cprogram

2024-09-30 06:13:53 发布

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

我试图从Python程序中调用一个名为“drule.C”的C程序drulewrapper.py公司”. 我试图使用“子流程”,但无法让它工作。你知道吗

1)我在Mac终端上编译“drule.c”,一切正常:

$ gcc -o drule drule c
$ ./drule D11
>P>Q>RQ

仅供参考,输入--“D11”--是谓词逻辑中的公理;输出--“>;p>;Q>;RQ”--是已证明的定理,然后我想在Python程序中进一步处理它。你知道吗

2)我编写了一个简短的Python程序(drulewrapper.py公司)并进行编译:

From subprocess import call
def CheckString():
     call(“./drule”, “D11”)

3)但是当我运行CheckString()时,会出现错误:

    Traceback (most recent call last):
  File "<pyshell#7>", line 1, in <module>
    CheckString()
  File "/Users/georgeszpiro/Dropbox/metamath/GApl/drulewrapper.py", line 3, in CheckString
    call("./drule","D11")
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 267, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 609, in __init__
    raise TypeError("bufsize must be an integer")
TypeError: bufsize must be an integerT

有人能帮忙吗?你知道吗


Tags: inpygt程序linelibrary公司call

热门问题