Tag:python Dynamic Language c# operation Dynamic language c# operation python
ususing system;using system.collections.generic;using system.componentmodel;using system.data;using system.drawing;using system.linq;using system.text;using system.threading.tasks;using system.windows.forms;using microsoft.scripting.hosting;using ironpython.hosting;using system.io;using system.dynamic;namespace windowsformsapplication2{ public partial class form1 : form { public form1 () { initializecomponent (); } private Void form1_load (object sender, eventargs e) { } /// <summary> /// calculations (referencing external files) /// </summary> /// <param name= "Sender" ></param> /// <param name= "E" ></param> private void but_compute_click (object sender, eventargs e) { string scriptpath = ""; if (rbut_Price.Checked) scriptpath = directory.getcurrentdiRectory () + "/a.py"; else scriptpath = directory.getcurrentdirectory () + "/b.py"; //Dynamic Language Environment Object scriptruntime script = python.createruntime (); //Language Engine Objects Scriptengine engine = script. Getengine ("Python"); //Specify script file scriptsource source = engine. Createscriptsourcefromfile (scriptpath); //create an object that hosts parameters scriptscope scope = script. Createscope (); //specify parameters and set values scope. SetVariable ("A", convert.todecimal (txt_price.text)); //executes the statement source. Execute (scope); //show Out Parameters lbl_result.text = scope. GetVariable ("B"). ToString (); } // / <summary> /// Direct Internal Computing /// ≪/summary> /// <param name= "Sender" ></ Param> /// <param name= "E" ></param> private void button1_click (object sender, Eventargs e) { //Dynamic Objects Dynamic dyn = new expandoobject (); dyn.name = "Hunter"; scriptruntime script = python.createruntime (); scriptengine engine= script. Getengine ("py"); scriptsource source = engine. Createscriptsourcefromstring ("Dyn.name= ' Code:: Hunter:: '"); scriptscope scope = engine. Createscope (); //Set Parameters scope. SetVariable ("dyn", dyn); //execution source. Execute (scope); messagebox.show (scope. GetVariable ("dyn"). name);//Output: Code:: Hunter:: } private void button2_click (Object sender, eventargs e) { &nbSp; scriptruntime script = python.createruntime (); dynamic dyn = script. Usefile (Directory.GetCurrentDirectory () + "/c.py"); messagebox.show (Dyn.getvalue ("Hello Hunter")); } }}
650) this.width=650; "style=" Float:none; "title=" spximage63.jpg "alt=" wkiol1qi4gazy-gdaacld4s4vf8566.jpg "src=" http ://s3.51cto.com/wyfs02/m02/4a/1e/wkiol1qi4gazy-gdaacld4s4vf8566.jpg "/>
650) this.width=650; "style=" Float:none; "title=" spximage64.jpg "src=" http://s3.51cto.com/wyfs02/M01/4A/1E/ Wkiol1qi5tcbmvyeaaalngwurns830.jpg "alt=" Wkiol1qi5tcbmvyeaaalngwurns830.jpg "/>
650) this.width=650; "style=" Float:none; "title=" spximage65.jpg "src=" http://s3.51cto.com/wyfs02/M01/4A/1C/ Wkiom1qi5q3hojzwaaalosspmqw720.jpg "alt=" Wkiom1qi5q3hojzwaaalosspmqw720.jpg "/>
650) this.width=650; "style=" Float:none; "title=" spximage66.jpg "src=" http://s3.51cto.com/wyfs02/M01/4A/1C/ Wkiom1qi5q2xzi2maabcoesixo4949.jpg "alt=" Wkiom1qi5q2xzi2maabcoesixo4949.jpg "/>
650) this.width=650; "style=" Float:none; "title=" spximage67.jpg "src=" http://s3.51cto.com/wyfs02/M02/4A/1E/ Wkiol1qi5tdc-3cdaabse_hrpxq642.jpg "alt=" Wkiol1qi5tdc-3cdaabse_hrpxq642.jpg "/>
Need the library to go to my download inside to download
This article is from the "program Ape's Home--hunter" blog, please be sure to keep this source http://962410314.blog.51cto.com/7563109/1557911
C # operation Dynamic language----Python