GIS项目中为了方便,我把python和nodejs环境设置成了免安装的.Unity开启进程时发现路径有空格会调用不成功.
API参考
spaces are interpreted as a separator between multiple arguments. 也就是 .NET把 空格当成了分隔符,路径后面就变成了多个参数.
1 2 3 4 5 |
// An argument with spaces inside quotes is interpreted as multiple arguments. // Output of ArgsEcho: // [0] = /a // [1] = literal string arg startInfo.Arguments = "/a \"literal string arg\""; |
如果”/a \”literal string arg\”” 写成”/a literal string arg” 则表示有4个参数,字符串里加了个转义 ,就变成2个参数了
1 2 3 4 5 6 7 8 9 |
// An argument inside double quotes is interpreted as if the quote weren't there, // that is, as separate arguments. Equivalent verbatim string is @"/a /b:""string with quotes""" // Output of ArgsEcho: // [0] = /a // [1] = /b:string // [2] = in // [3] = double // [4] = quotes startInfo.Arguments = "/a /b:\"\"string in double quotes\"\""; |
“/a /b:\”\”string in double quotes\”\”” 相当于@”/a /b:””string with quotes”””, /b:””string等于/b:string,双引号没什么意义.
1 2 3 4 5 |
// Triple-escape quotation marks to include the character in the final argument received // by the target process. Equivalent verbatim string: @"/a /b:"""quoted string"""; // [0] = /a // [1] = /b:"quoted string" startInfo.Arguments = "/a /b:\"\"\"quoted string\"\"\""; |
“/a /b:\”\”\”quoted string\”\”\””相当于@”/a /b:”””quoted string”””,去掉其中的双引号变成 /a /b:”quoted string”