LoginSignup
1
0

More than 5 years have passed since last update.

pythonでhello world

Posted at

概要

pythonで、gcc使って、hello worldやってみた。

サンプルコード

import subprocess
import os

def gcc():
    c_file = 'hello.c'
    test_c = """
#include<stdio.h>
int main()
{
    printf("Hello World!\\n");
    return 0;
}
"""
    with open(c_file, 'w') as f:
        f.write(test_c)
    os.system("gcc %s" % c_file)
    result = subprocess.Popen('./a.out', stdout=subprocess.PIPE).communicate()[0]
    for i, v in enumerate(result[:-1].split('\n')):
        print v

if __name__ == '__main__':
  gcc()

成果物

以上。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0