|
楼主 |
发表于 2025-7-22 15:36:55
来自手机
|
显示全部楼层
laojun001 发表于 2025-7-14 16:47
脚本语言代码与python一般程序代码是不一样的,要看应用在哪里了,要看应用手册编写脚本才行的,都是有原则 ...
import re
import os
import sys
import subprocess
global file_path_1
new_lines=[]
file_name_1 =sya.argv[1]
file_name_1_cp ="chosed_module_" +file_name_1
current_path os.getcwd()
def remove_module_blocks():
file_path_1 =os.path.join(current_path,file_name_1)
print (f"file_path_1 is {file_path_1}")
with open{file_path_1,'r'}as f:
lines_read=f.readlines()
for line in lines_read:
match=re.search(r'module\s+."same_module\(',line)
if match:
continue
while "endmodule" in line:
continue
else:
new_lines.append(line)
with open{file_path_1,'w'}as f:
f.writelines(new_lines)
这是我写的代码,运行时没报错,但对目标文件没产生任何变化,你能帮我看看为什么吗 |
|