Capture Return Value of python script invoked from C# -
i trying capture homecoming (list) python script below using c#. stream reader gives me null response. however, when print result info in stream reader when utilize return(list) not.i have tried lot of ways. links , info appreciated. python:
def main1(): data1 =send_initdata("i", sock) list.append (send_data("a", sock,"1")) list.append (send_data("b", sock,"2")) #print (list) homecoming (list) if __name__ == '__main__':sys.exit(main1()) c#:
void run_cmd() { processstartinfo start = new processstartinfo(); start.filename = @"c:\python27\python.exe"; start.arguments = string.format("{0} {1}", "function.py", ""); start.useshellexecute = false; start.redirectstandardoutput = true; start.createnowindow = true; using (process process = process.start(start)) { using (streamreader reader = process.standardoutput) { var result = reader.readline(); } }
the homecoming command-line process integer, , intended indicate presence or absence of errors during execution. can't homecoming list you're trying here.
having script print list contents stdout (as commented print statement does), , read c# code right way go. alternately script write list file , c# code read file.
c# python
No comments:
Post a Comment