用法:
toreadonly()
返回 memoryview 對象的隻讀版本。原始的 memoryview 對象沒有改變。
>>> m = memoryview(bytearray(b'abc')) >>> mm = m.toreadonly() >>> mm.tolist() [89, 98, 99] >>> mm[0] = 42 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: cannot modify read-only memory >>> m[0] = 43 >>> mm.tolist() [43, 98, 99]
3.8 版中的新函數。
相關用法
- Python memoryview.tolist用法及代碼示例
- Python memoryview.tobytes用法及代碼示例
- Python memoryview.itemsize用法及代碼示例
- Python memoryview.nbytes用法及代碼示例
- Python memoryview.cast用法及代碼示例
- Python memoryview.obj用法及代碼示例
- Python memoryview.hex用法及代碼示例
- Python memoryview.release用法及代碼示例
- Python memoryview.__eq__用法及代碼示例
- Python memoryview()用法及代碼示例
- Python memoryview用法及代碼示例
- Python statistics median_high()用法及代碼示例
- Python statistics median_low()用法及代碼示例
- Python statistics median()用法及代碼示例
- Python statistics median_grouped()用法及代碼示例
- Python numpy ma.MaskedArray.view用法及代碼示例
- Python matplotlib.patches.Rectangle用法及代碼示例
- Python matplotlib.pyplot.step()用法及代碼示例
- Python math.cos()用法及代碼示例
- Python math.cosh()用法及代碼示例
注:本文由純淨天空篩選整理自python.org大神的英文原創作品 memoryview.toreadonly。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。