在文件路径中使用空格字符运行程序大家好,
目前,我正在努力执行包含空格字符的文件路径的runprogram命令:
myPath = "C:\Users\FilePath\Test.py"
myInfo = runprogram(executable("python"), options({myPath}),readfunction("text"));
这工作得很好,但是当文件路径包含空格时 - 路径被切断,因此无法找到文件:
myPath = "C:\Users\File Path\Test.py"
myInfo = runprogram(executable("python"), options({myPath}),readfunction("text"));也许有人可以帮助我 - 谢谢,
总干事
高级统计建模消费者和市场研究质量和工艺工程回复:在文件路径中使用空格字符运行程序嗨克雷奇,
非常感谢 - 实际上我看到了帖子,但没能适应它。
再次感谢,完美的作品!
回复:在文件路径中使用空格字符运行程序先前关于使用引号的评论: https://community.jmp.com/t5/Discussions/Unable-to-parse-speechmarks-quot-quot-into-powershell-using/mp/245968/highlight/true#M48328
您可以使用 CMD 窗口(黑色 DOS 框窗口)来查看 Windows 如何使用引号完成命令:
Use quotation marks around parameters with embedded spacesUse quotation marks around parameters with embedded spacesUse quotation marks around parameters with embedded spaces在带有嵌入空格的参数周围使用引号
完成该操作后,您需要将其放入 JMP 字符串中,这需要进行某种转义,因为 JMP 也使用引号。 对于此示例,只需使用 \!" 转义两个引号即可。
filename = "c:\Program Files\Common Files\System\Ole DB\oledbjvs.inc";
write("filename = ", filename); // no quotation marks
txt = runprogram(executable("python"), options({
"\!"" || filename || "\!""
}),readfunction("text"));使用 JMP 中的“write”函数,而不是“print”函数,后者通过用引号将打印的文本引起更多的混淆。
您还可以将引号构建到字符串中,但是如果您从 filesInDirectory 函数之类的东西中获取文件名,则上面的 JSL 是您所需要的……您仍然需要添加它们。 即使不需要,您也可以添加引号。 如果出于某种原因在文件名中间有引号,请参阅顶部的链接。