c# - 我如何将整个路径从 python 传递到 c#?

标签 c# python image variables

我不太擅长 C#,我需要帮助。我创建了一个 python 代码来循环文件夹内的文件,这是代码:

path = os.path.expanduser('~\\Desktop\\image\\')
images = os.listdir(path)
sorted_imgs = images.sort(key=lambda x: int(x.split('.')[0]))

for i, roi in enumerate(images):

    img = (path + roi)
    print(img)

这给了我我想要的道路。现在我需要将此路径传递到 C# 脚本内的变量中,其中变量的名称是“image”。我该怎么做?

感谢您的帮助和您的时间。

最佳答案

最好在 C# 脚本中添加一个占位符,例如 ###IMAGEPATH### 并使用类似

with open('script.cs', 'rt') as f:
    x = f.read

x.replace('###IMAGEPATH###', path_found)        

with open('script_2.cs', 'wt') as f:
    f.write(x)

关于c# - 我如何将整个路径从 python 传递到 c#?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48688375/

相关文章:

javascript - 在node.js中使用GM裁剪成带圆圈的图片

c# - UITextField TextColor 属性绑定(bind)问题(MVVMCross)

c# - XAML MVVM DatePicker - 如何获取数据?

c# - 在数据库中存储动态JSON数据并通过键值搜索

c# - 用于搜索日期的 SQL 查询

python - web.py + lighttpd + matplotlib 不工作

python - 在 Ubuntu 系统中安装 Jupyter

python-3.x - 在 tensorflow 中预处理不同的图像尺寸

python - 我可以使用整数在 python 中使用 unicode 吗?

JavaScript/CSS : Make image expand up and to left on rollover effect