Home
Sign Up
Sign In
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member
Sign In
V2EX
›
xcai007
›
全部回复第 2 页 / 共 2 页
回复总数
21
1
2
❮
❯
2020 年 10 月 29 日
回复了
hhvv23911k
创建的主题
›
Python
›
请教如何使用 Python 直接对二进制文件进行修改
用 mmap
import mmap
with open('file', 'rb) as f:
with mmap.mmap(f.fileno(), length=0, access=mmap.ACCESS_READ) as contents:
start = contents.find('test')
print(contents[:start]+'mytest'+contents[start+len('test'):]
1
2
❮
❯
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Solana
·
5428 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 15ms ·
UTC 07:18
·
PVG 15:18
·
LAX 00:18
·
JFK 03:18
♥ Do have faith in what you're doing.
❯