python替换文件内容
# 打开文件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(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)