【发布时间】:2018-03-21 23:18:20
【问题描述】:
我想将 file1.v 中的特定代码行(两个特定行之间的代码)附加到 file2.sv 中
我正在尝试借助 subprocess 模块从 python 运行外部 perl 脚本。这个外部 perl 脚本为我创建了“file2.sv”。 file1.v 已经存在。
我的问题是 file2.sv 是由 perl 脚本成功创建的,但是我试图从 file1.v 将行附加到 file2.sv 的代码不起作用
代码如下:
pipe = subprocess.Popen(
["Verilog.pl", "file1.v", "file2.sv", "0", "SystemVerilog", "SV","0"], stdin=subprocess.PIPE)
with open("file1.v","r") as rf_VamsModel, open("file2.sv", "a") as wf_sytemVerilogFile:
copy = False
for line in rf_VamsModel:
if line.strip() == "//Start of functional specification here":
copy = True
elif line.strip() == "//End of functional specification here":
copy = False
elif copy:
print("line test2={}".format(line))
wf_sytemVerilogFile.write(line)
是不是因为 subprocess.Popen 和 file append 进程是并行执行的?
【问题讨论】:
标签: python subprocess