2017-03-18 24 views
0

我有这样的代码在批处理文件:翻译批处理文件成Python,其中一个exe应该与它的参数来运行

所有的
D:\Programmes\POISSON\PoissonRecon.x64\PoissonRecon.exe --in D:\Programmes\POISSON\fichier1_test.ply --color 16 --depth 10 --out fichier1_test_poisson.ply --density --samplesPerNode 1.50 --fullDepth 5 --pointWeight 4 --bType 2 

首先,我想在Python“翻译”了。

但是,对于1个文件(该路径在代码中写为“--in”),这是一个简单的情况。

因此,第二次,我想编写相同的Python代码,但不仅针对一个文件,而且针对位于特定文件夹中的每个.ply文件。 (如果执行python脚本,它会很好,如果它可以问我所有.ply文件所在的文件夹的路径)。

我想应该使用for循环吗?还有变量?

我有0级在Python ...所以任何想法将非常感激:)

我曾尝试这个代码,但它不工作:/

import subprocess, os 

s = r'D:\Programmes\POISSON\PoissonRecon.x64\PoissonRecon.exe' 

subprocess.Popen(["s", "--in D:\Programmes\POISSON\fichier1_test.ply", "--color 16", "--depth 9", "--out fichier1_test_poisson.ply", "--density", "--samplesPerNode 1.50", "--fullDepth 5", "--pointWeight 4", "--bType 2"]) 

回答

0

每个命令行参数需要自己的字符串,就像这样:

import subprocess, os 

s = r'D:\Programmes\POISSON\PoissonRecon.x64\PoissonRecon.exe' 

subprocess.Popen(
    [ 
     s, 
     "--in", "D:\Programmes\POISSON\fichier1_test.ply", 
     "--color", "16", 
     "--depth", "9", 
     "--out", "fichier1_test_poisson.ply", 
     "--density", 
     "--samplesPerNode", "1.50", 
     "--fullDepth", "5", 
     "--pointWeight", "4", 
     "--bType", "2" 
    ] 
) 
+0

你忘了,而重要的组成部分:其实传递命令字符串作为变量's',不包含字符串的字母S,'“S”'。 – ShadowRanger

+0

谢谢,忽略了:) – Julien

相关问题