1、写文件
with open(‘??‘, ‘r+b‘) as f: with contextlib.closing(mmap.mmap(f.fileno(), size, flags=mmap.MAP_SHARED, access=mmap.ACCESS_WRITE)) as mm: mm = ?? mm.flush()
2、重点提醒
>>> mmap.ACCESS_READ
1
>>> mmap.ACCESS_WRITE
2
>>> mmap.ACCESS_COPY
3
>>> mmap.ACCESS_READ | mmap.ACCESS_WRITE
3
In other words, access=mmap.ACCESS_READ|mmap.ACCESS_WRITE
is the same as access=mmap.ACCESS_COPY
. What you want is most likely access=mmap.ACCESS_WRITE
, and on Windows that‘s what you get anyway if you don‘t explicitly use that argument.
时间: 2024-10-13 20:36:54