此函数用于通过使用指定的缓冲区来创建数组。
句法
numpy.frombuffer(buffer, dtype = float, count = -1, offset = 0)
参数
它接受以下参数。
- 缓冲区:它表示暴露缓冲区接口的对象。
- dtype:代表返回的数据类型数组的数据类型。默认值为0。
- count:代表返回的ndarray的长度。默认值为-1。
- 偏移量:代表读取的起始位置。默认值为0。
返回
返回缓冲区的数组版本。
例子
import numpy as np
l = b'hello world'
print(type(l))
a = np.frombuffer(l, dtype = "S1")
print(a)
print(type(a))
输出
[b'h' b'e' b'l' b'l' b'o' b' ' b'w' b'o' b'r' b'l' b'd']
来源:
https://www.srcmini02.com/30816.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_35711.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57