import os
import subprocess
rootdir=os.path.join('D:\SPI1')#修改自己的路径
for (dirpath,dirnames,filenames) in os.walk(rootdir):
for filename in filenames:
if os.path.splitext(filename)[1]=='.txt':
# write_path.write('要写的绝对路径'+filename+'\n')
proc = subprocess.Popen('SPI_SL_6.exe', stdin=subprocess.PIPE)
proc.stdin.write(b"3\n")
proc.stdin.write(b"1\n")
proc.stdin.write(b"3\n")
proc.stdin.write(b"12\n")
proc.stdin.write(b"SP1/"+filename.encode()+b"\n")#修改自己的路径
proc.stdin.write(b"SP2/"+filename.encode()+b"\n")#修改自己的路径
proc.stdin.flush()
proc.stdin.close()
python调用exe文件并向其中输入参数(多用于批处理)
最新推荐文章于 2024-05-17 15:13:44 发布
本文档展示了如何使用Python脚本`SPI_SL_6.exe`处理文本文件,通过读取目录并逐个将.txt文件上传到SP1和SP2路径。主要涉及文件操作和进程调用。
&spm=1001.2101.3001.5002&articleId=120985783&d=1&t=3&u=c82f604d3a164c8180237a9a23559ef2)
831

被折叠的 条评论
为什么被折叠?



