用法:
class wsgiref.util.FileWrapper(filelike, blksize=8192)
將 file-like 對象轉換為迭代器的包裝器。生成的對象同時支持
__getitem__()
和__iter__()
迭代樣式,以便與 Python 2.1 和 Jython 兼容。隨著對象的迭代,可選的blksize
參數將重複傳遞給filelike
對象的read()
方法以獲取要產生的字節串。當read()
返回空字節串時,迭代結束且不可恢複。如果
filelike
有close()
方法,返回的對象也會有close()
方法,調用時會調用filelike
對象的close()
方法。示例用法:
from io import StringIO from wsgiref.util import FileWrapper # We're using a StringIO-buffer for as the file-like object filelike = StringIO("This is an example file-like object"*10) wrapper = FileWrapper(filelike, blksize=5) for chunk in wrapper: print(chunk)
自 3.8 版起已棄用:支持
sequence protocol
已棄用。
相關用法
- Python wsgiref.util.setup_testing_defaults用法及代碼示例
- Python wsgiref.simple_server.make_server用法及代碼示例
- Python wsgiref.validate.validator用法及代碼示例
- Python OpenCV waitKeyEx()用法及代碼示例
- Python winsound.SND_ALIAS用法及代碼示例
- Python weakref.WeakMethod用法及代碼示例
- Python OpenCV waitKey()用法及代碼示例
- Python cudf.core.column.string.StringMethods.is_vowel用法及代碼示例
- Python torch.distributed.rpc.rpc_async用法及代碼示例
- Python torch.nn.InstanceNorm3d用法及代碼示例
- Python sklearn.cluster.MiniBatchKMeans用法及代碼示例
- Python pandas.arrays.IntervalArray.is_empty用法及代碼示例
- Python tf.compat.v1.distributions.Multinomial.stddev用法及代碼示例
- Python numpy.less()用法及代碼示例
- Python tf.compat.v1.distribute.MirroredStrategy.experimental_distribute_dataset用法及代碼示例
- Python Sympy Permutation.list()用法及代碼示例
- Python dask.dataframe.Series.apply用法及代碼示例
- Python scipy.ndimage.binary_opening用法及代碼示例
- Python pyspark.pandas.Series.dropna用法及代碼示例
- Python torchaudio.transforms.Fade用法及代碼示例
注:本文由純淨天空篩選整理自python.org大神的英文原創作品 wsgiref.util.FileWrapper。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。