Python照片浏览变量传递

本文关键字:变量 浏览 照片 Python | 更新日期: 2023-09-27 18:15:40

我正在做一个网络摄像头项目,我试图使用c#运行一个python脚本与位置变量传递给python,所以我可以不断改变图像的打开/保存位置。

这是用来传递图像的开口位置来进行裁剪。

string loca = File.ReadAllText("cropface.py").Replace("%location%", "C:''Users''L31101''Desktop''Camera''Camera''bin''Debug''center''center.jpg");
            File.WriteAllText("cropface.py", loca);

然而,我的python脚本接收位置没有2反斜杠

image =  Image.open("C:'Users'L31101'Desktop'Camera'Camera'bin'Debug'center'center.jpg")

因此,我尝试传递正向斜杠而不是2个反斜杠,然而我的python脚本仍然收到1个反斜杠。

你知道怎么绕过它吗?

Python照片浏览变量传递

代替

"C:''Users''L31101''Desktop''Camera''Camera''bin''Debug''center''center.jpg";

@"C:''Users''L31101''Desktop''Camera''Camera''bin''Debug''center''center.jpg";

则传递两个backslash。