因此,我有一个C#代码,它将图像转换为base64,反之亦然。现在,我想将生成的base64发送到python
这是我现有的代码
var startProcess = new ProcessStartInfo
{
FileName = pythonInterpreter,
Arguments = string.Format($"\"{pythonPathAndCode}\" {b64stringCSharp}"),
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardInput = true,
RedirectStandardError = true,
CreateNoWindow = true,
};
using (Process process = Process.Start(startProcess))
{
error = process.StandardError.ReadToEnd();
testResult = process.StandardOutput.ReadToEnd();
lblTestOutput.Text = testResult;
lblError.Text = error;
}
当我试图向python发送一个字符串的小值时,这段代码工作得很好。但在发送base64值时,出现了异常错误
System.ComponentModel.Win32Exception: 'The filename or extension is too long'
请注意,当我只发送32000个或更少的字符串,但base64由98260组成时,代码运行得非常好
有没有办法最小化这个base64
这是我的python代码:
import sys
inputFromC = sys.stdin
print("Python Recevied: ", inputFromC)
Windows中命令+参数的最大长度为32767个字符(link)。这和你看到的是一致的
我建议改为通过进程的标准输入发送图像。比如:
显然,修改Python脚本以从标准输入读取,而不是从命令行参数读取
相关问题 更多 >
编程相关推荐