# 打开文件
with open(name, 'r') as file:
content = file.read()
# 替换内容
old_string = 'binary'
new_string = 'cc_library_shared'
content = content.replace(old_string, new_string)
# 写回文件
with open(name, 'w') as file:
file.write(content)
# 打开文件
with open(file_name, 'r') as file:
lines=file.readlines()
flag1 = "On::"
new1 = "Onxxxx\n"
# 写回文件
with open(file_name, 'w') as file:
for line in lines:
# if old in line :
ps = line.find(flag1)
if ps != -1:
context = line[:ps]
context += new1
# context = line.replace(flag1,"")
file.write(context)
continue
file.write(line)