示例#1
0
        public void ToNullTextWriter()
        {
            // redirect to a TextWriter
            PySysIO.ToTextWriter();

            //test
            using (Py.GIL())
            {
                PythonEngine.RunSimpleString("print('hello NullTextWriter!')");
            }
        }
示例#2
0
        public void ToTextWriter()
        {
            // redirect to a TextWriter
            PySysIO.ToTextWriter(new StringWriter());

            //test
            using (Py.GIL())
            {
                PythonEngine.RunSimpleString("print('hello TextWriter!')");
            }

            var writer  = PySysIO.TextWriter as StringWriter;
            var content = writer.GetStringBuilder().ToString();

            Console.WriteLine(content);
        }