LoginSignup
0
0

More than 5 years have passed since last update.

pythonでhello world その2

Posted at

概要

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

サンプルコード

# coding: utf-8
# Your code here!

import subprocess
import os

def mcs():
    cs_file = 'Hello.cs'
    test_cs = """
public class Hello{
    public static void Main(){
        System.Console.WriteLine("Hello C#");
    }
}
"""
    with open(cs_file, 'w') as f:
        f.write(test_cs)
    os.system("mcs %s" % cs_file)
    cmd = "mono Hello.exe"
    result = subprocess.Popen(cmd.split(), stdout = subprocess.PIPE).communicate()[0]
    for i, v in enumerate(result[ : -1].split('\n')):
        print v

if __name__ == '__main__':
  mcs()

成果物

以上。

0
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
0
0