我有大量用于偏移量06和07的文件“ 01 01”而不是“ 00 00”,因此我想制作一个python脚本,但是运行它时,没有错误发生,并且没有文件被更改。这是我的脚本:
for g in os.listdir('./'):
if not os.path.isfile(g):
continue
file = open(g, "rb")
magic = file.read(8)
magic[6]==0
magic[7]==0
编辑:哦,我忘了关闭文件,并且'rb'仅用于读取二进制,因此这是我的新代码(由于字符00不存在,因此仍然无法使用)
for g in os.listdir('./'):
if not os.path.isfile(g):
continue
with file(g, 'rb') as fh:
patch1 = �
with file(g, 'r+b') as fh:
fh.seek(0x06)
fh.write(patch1)
fh.seek(0x07)
fh.write(patch1)```