我正在尝试在可可应用程序中运行以下内容:
cat PATHTOFILE | python -mjson.tool > 输出文件
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath: @"/bin/cat"];
NSArray *arguments = [NSArray arrayWithObject: path];
[task setArguments: arguments];
NSPipe *pipe = [NSPipe pipe];
[task setStandardOutput:pipe];
[task launch];
NSTask *task2 = [[NSTask alloc] init];
[task2 setLaunchPath:@"/usr/bin/python"];
NSArray *arguments2 = [NSArray arrayWithObject:[NSString stringWithFormat:@"-mjson.tool > %@.beautify", path]];
[task2 setArguments:arguments2];
[task2 setStandardInput:pipe];
NSPipe *pipe2 = [NSPipe pipe];
[task2 setStandardOutput:pipe2];
[task2 launch];
但是我收到以下错误:/usr/bin/python:不支持按文件名导入。
有任何想法吗?