Skip to Content
Python 技術手冊 第三版
book

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate to advanced content levelIntermediate to advanced
856 pages
17h 17m
Chinese
GoTop Information, Inc.
Content preview from Python 技術手冊 第三版
mmap 模組
|
479
poll p.poll()
檢查子行程是否終止了,然後回傳
p.returncode
wait p.wait()
等候子行程終止,然後回傳
p.returncode
。在 v3 中,也接受一個選擇性
timeout
引數。
mmap 模組
mmap
模組提供記憶體映射(memory-mapped)的檔案物件。一個
mmap
物件
的行為類似於一個位元組字串(bytestring),所以你通常可以把一個
mmap
物件傳入預期位元組字串的地方。然而,還是有差異存在:
mmap
物件不提供字串物件的方法。
mmap
物件是可變的,然而字串物件是不可變的。
一個
mmap
物件也對應到一個開啟的檔案,其行為與 Python 的檔案物件
多型(如前面的「類檔案物件與多型」中所涵蓋的)。
一個
mmap
物件
m
也可以被索引或切片,產出位元組字串。因為
m
是可變
的,你也可以對
m
的一個索引動作或切片動作進行指定(assign)。然而,
當你指定至
m
的一個切片,指定述句的右手邊必須是一個位元組字串,其
長度與作為你指定目標的切片完全相同。因此,串列切片指定(涵蓋於
前面的「修改一個串列」中)的許多實用技巧有許多不適用於
mmap
切片
指定。
mmap
模組提供一個工廠函式(factory function),它在類 Unix 系統上和在
Windows 上有些微的差異:
mmap mmap(filedesc,length,tagname='', access=None, offset=None)
Windows
mmap( ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

測試驅動開發|使用 Python

測試驅動開發|使用 Python

Harry J.W. Percival
Linux 内核观测技术BPF

Linux 内核观测技术BPF

David Calavera, Lorenzo Fontana

Publisher Resources

ISBN: 9789864766819