python 内存映射文件
2012-06-23 10:07
357 查看
可以直接吧内存的对象作为 类 list file 读写赋值啦。
好方便!
eg:
好方便!
eg:
import mmap # write a simple example file with open("hello.txt", "wb") as f: f.write(b"Hello Python!\n") with open("hello.txt", "r+b") as f: # memory-map the file, size 0 means whole file map = mmap.mmap(f.fileno(), 0) # read content via standard file methods print(map.readline()) # prints b"Hello Python!\n" # read content via slice notation print(map[:5]) # prints b"Hello" # update content using slice notation; # note that new content must have same size map[6:] = b" world!\n" # ... and read again using standard file methods map.seek(0) print(map.readline()) # prints b"Hello world!\n" # close the map map.close()
相关文章推荐
- python 科学计算学习一:numpy文件存取,内存映射
- python-18-如何将文件映射到内存?
- python 5-4 如何将文件映射到内存mmap.mmap(f.fileno(),0,access=mmap.ACCESS_WRITE)
- python小点心--内存文件映射
- python 科学计算学习一:numpy文件存取,内存映射
- python文件读写(open参数,文件缓冲,内存映射,临时文件)
- 页文件支持的内存映射文件
- Java nio 之 内存映射文件
- Delphi 中内存映射对于大文件的使用
- VC++中使用内存映射文件处理大文件
- mmap映射文件至内存( 实现 共享内存 与 文件的另类访问 )
- VC++中使用内存映射文件处理大文件
- VC++中使用内存映射文件处理大文件
- VC++ 中使用内存映射文件处理大文件
- windows笔记-页文件支持的内存映射文件
- C# .Net 多进程同步 通信 共享内存 内存映射文件
- iOS内存优化--大文件如何处理,内存映射
- VC++中使用内存映射文件处理大文件 (1)
- 如何将文件映射到内存
- VC++中使用内存映射文件处理大文件