mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
Binary flag is needed on windows.
This commit is contained in:
parent
b0e10c760c
commit
02172ddbee
1 changed files with 2 additions and 2 deletions
|
@ -99,10 +99,10 @@ memory but does not update the underlying file.
|
||||||
import mmap
|
import mmap
|
||||||
|
|
||||||
# write a simple example file
|
# write a simple example file
|
||||||
with open("hello.txt", "w") as f:
|
with open("hello.txt", "wb") as f:
|
||||||
f.write("Hello Python!\n")
|
f.write("Hello Python!\n")
|
||||||
|
|
||||||
with open("hello.txt", "r+") as f:
|
with open("hello.txt", "r+b") as f:
|
||||||
# memory-map the file, size 0 means whole file
|
# memory-map the file, size 0 means whole file
|
||||||
map = mmap.mmap(f.fileno(), 0)
|
map = mmap.mmap(f.fileno(), 0)
|
||||||
# read content via standard file methods
|
# read content via standard file methods
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue