在 Windows 上从 Python 运行 C 程序

问题描述

我试图按照 this tutorial 在 python 中执行 C 程序。该教程提到它仅适用于 linux。让它在 Windows 10 上运行的正确方法是什么?

# Python 3 program to demonstrate subprocess 
# module
  
import subprocess
import os
  
def excuteC():
  
    # store the return code of the c program(return 0)
    # and display the output
    s = subprocess.check_call("gcc HelloWorld.c -o out1;./out1",shell = True)
    print(",return code",s)



#include<stdio.h>
int main()
{
    printf("Hello World from C");
  
    // returning with any other non zero value
    // would result in an exception
    // when called from python
    return 0;
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)