我想问如何在运行进程之前更新变量时运行外部批处理文件。我的问题的细节如下:
我现在有一个批处理文件,而它正在执行一个模拟过程。我想编写一个模块,在不手动更新批处理文件的情况下首先更新变量,然后运行模拟,最后导入结果,如下所示:
# this will be the variable that I want to update
yyyy = 2022
mm = 11
dd = 28
Path1 = 'the path for first variable'
Path2 = 'the path for second variable'
# the batch file is like:
Batch_simulation.bat
Path 2/remote/noclear/Path 1/%yyyy%%mm%%dd%
# therefore, I want to update the variable in batch file first, then run the simulation, my code is looking like this right now:
import subprocess
yyyy = 2022
mm = 11
dd = 28
Path1 = 'the path for first variable'
Path2 = 'the path for second variable'
paramStr = str(yyyy)+','+str(mm)+','+str(dd)+','+Path1+','+Path2
bat_file = ['pathway for Batch_simulation.bat', paramStr]
process = subprocess.run([bat_file])
stdout, stderr = process.communicate()有人能给我一些建议或任何可能的解决方案吗?非常感谢
发布于 2022-11-28 20:02:27
有人能给..。有没有可能的解决办法.?
https://stackoverflow.com/questions/74605590
复制相似问题