我不太擅长 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/