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-02-05 09:41:30 发布
本文档展示了如何使用Python脚本`SPI_SL_6.exe`处理文本文件,通过读取目录并逐个将.txt文件上传到SP1和SP2路径。主要涉及文件操作和进程调用。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Python3.9
Conda
Python
Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本
753

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



