python询问是否继续_Python文件询问批处理文件是否继续

请参考以下代码,该代码创建批处理文件以同步执行某些程序。但在执行第一个文件后,程序停止并询问是否继续批处理。这会导致用户输入延迟。因为我希望在一夜之间运行几个文件,所以程序会等待用户输入。有人能帮我解决这个错误吗?在import os

from subprocess import call

version = "0.1"

os.system('CLS')

print("")

print("// LS-DYNA Simulation Start Script, V" + version + " //")

print("\n")

input_flag = 0

while input_flag == 0:

solver_type_string = raw_input("Use single or double precision solver (s/d)?")

if solver_type_string == "s":

solver_type_string = "ls971_s_R5.1.1_winx64_p.exe"

print("Choosen Solver: " + solver_type_string + "\n")

input_flag = 1

elif solver_type_string == "d":

solver_type_string = "ls971_d_R5.1.1_winx64_p.exe"

print("Choosen Solver: " + solver_type_string + "\n")

input_flag = 1

else:

print("Invalid input!\n")

current_path = os.path.dirname(os.path.abspath(__file__))

solver_path = "C:\Programme\LSDyna-971.1\program\\" + solver_type_string

batch_file = open("sim_start.bat", "w")

batch_file.write("@echo off\n")

sim_counter = 0

for (path, dirs, files) in os.walk(current_path):

for sim_file in files:

if sim_file.endswith((".k", ".dyn")):

sim_counter = sim_counter + 1

sim_path = path

print("Found: \'" + sim_file + "\'")

batch_file.write("pushd " + sim_path + "\\\n")

batch_file.write(solver_path + " i=" + sim_path + "\\" + sim_file + "\n")

print "\nDone! Found ", sim_counter, " simulation files in total."

batch_file.close()

print "\nStarting LS-DYNA batch run...\n"

call(current_path + "\sim_start.bat")

创建的文件看起来像

^{pr2}$

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值