15 lines
421 B
Python
15 lines
421 B
Python
def replace_null_bytes(file_path):
|
|
with open(file_path, 'rb') as f:
|
|
content = f.read()
|
|
|
|
# 替换所有的空字节
|
|
new_content = content.replace(b'\x00', b'')
|
|
|
|
# 以二进制模式写回文件
|
|
with open(file_path, 'wb') as f:
|
|
f.write(new_content)
|
|
|
|
print(f"已从 {file_path} 中移除空字节")
|
|
|
|
# 对配置文件执行替换操作
|
|
replace_null_bytes('core/config.py') |