當我執行單個文件的命令時,它的工作原理。然而,當我想在循環中使用它時,它不起作用。可能是什麼問題呢 ? 從子進口通話 進口操作系統,SYS傳遞exe文件到目錄中的所有文件到Python
rootdir = r'C:\\Users\\X\\Desktop\\hump'
for root, dirs, files in os.walk(rootdir):
for file in files:
if file.endswith(".ply"):
nf = file.replace('.ply', '.txt')
os.system("C:\\Users\\X\\Desktop\\fftw-3.3.5 dll64\\ShapeDescriptor.exe --in file --out nf")
忘記一分鐘的子過程,並想象如果您只是想構造一個包含文件名的字符串,您會做什麼。 –
我添加了一些像file_name = os.path.join(根,文件),然後將它與下面的答案合併 – edyvedy13