Passing data between Python and C# without writing a file

你说的曾经没有我的故事 提交于 2019-12-03 16:20:42

This python code was correct

p = Popen(C_SHARP_EXECUTABLE_FILE_PATH, stdout=PIPE, stdin=PIPE, stderr=PIPE)
out, err = p.communicate(blob)

And on the C# side, I got it to work with

Stream ms = Console.OpenStandardInput();

One possibility would be to use something like Python for .NET, which provides interop directly between C# and (standard, C) Python.

Depending on what your Python routines need to do, IronPython can also be a good option, as this is directly consumable and usable from within C#.

Both of these options avoid trying to communicate through the command line, as you have direct access to the Python objects from .NET, and vice versa.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!