当前位置:网站首页>numpy.frombuffer()
numpy.frombuffer()
2022-06-26 05:48:00 【Wanderer001】
参考numpy.frombuffer() - 云+社区 - 腾讯云
numpy.frombuffer
numpy.
frombuffer
(buffer, dtype=float, count=-1, offset=0)
Interpret a buffer as a 1-dimensional array.
Parameters: | buffer : buffer_like An object that exposes the buffer interface. dtype : data-type, optional Data-type of the returned array; default: float. count : int, optional Number of items to read. offset : int, optional Start reading the buffer from this offset (in bytes); default: 0. |
---|
Notes
If the buffer has data that is not in machine byte-order, this should be specified as part of the data-type, e.g.:
>>> dt = np.dtype(int)
>>> dt = dt.newbyteorder(‘>‘)
>>> np.frombuffer(buf, dtype=dt)
The data of the resulting array will not be byteswapped, but will be interpreted correctly.
Examples
>>> s = ‘hello world‘
>>> np.frombuffer(s, dtype=‘S1‘, count=5, offset=6)
array([‘w‘, ‘o‘, ‘r‘, ‘l‘, ‘d‘],
dtype=‘|S1‘)
>>> np.frombuffer(b‘\x01\x02‘, dtype=np.uint8)
array([1, 2], dtype=uint8)
>>> np.frombuffer(b‘\x01\x02\x03\x04\x05‘, dtype=np.uint8, count=3)
array([1, 2, 3], dtype=uint8)
NumPy的ndarray数组对象不能像list一样动态地改变其大小,在做数据采集时很不方便。本文介绍如何通过np.frombuffer()实现动态数组。
边栏推荐
- cross entropy loss = log softmax + nll loss
- Sofa weekly | open source person - Yu Yu, QA this week, contributor this week
- Daily production training report (16)
- Consul service registration and discovery
- Kolla ansible deploy openstack Yoga version
- Machine learning 05: nonlinear support vector machines
- LeetCode_ Binary search tree_ Simple_ 108. convert an ordered array to a binary search tree
- Owasp-top10 in 2021
- Introduction to lcm32f037 series of MCU chip for motor
- Ribbon负载均衡服务调用
猜你喜欢
操作符的优先级、结合性、是否控制求值顺序【详解】
Leetcode114. Expand binary tree into linked list
The difference between get and post in small interview questions
【C語言】深度剖析數據在內存中的存儲
DOM document
SDN based DDoS attack mitigation
421- binary tree (226. reversed binary tree, 101. symmetric binary tree, 104. maximum depth of binary tree, 222. number of nodes of complete binary tree)
Pytorch (environment, tensorboard, transforms, torchvision, dataloader)
bingc(继承)
421-二叉树(226. 翻转二叉树、101. 对称二叉树、104.二叉树的最大深度、222.完全二叉树的节点个数)
随机推荐
What management systems (Updates) for things like this
Machine learning 05: nonlinear support vector machines
Lesson 4 serial port and clock
Feelings of virtual project failure
BOM文档
Learn cache lines and pseudo sharing of JVM slowly
Daily production training report (16)
uniCloud云开发获取小程序用户openid
Redis installation on Linux
RIA想法
Pytorch (environment, tensorboard, transforms, torchvision, dataloader)
Old love letters
Yamaha robot splits visual strings
Pytorch (network model)
MySQL source code reading (II) login connection debugging
一段不离不弃的爱情
Positioning setting horizontal and vertical center (multiple methods)
Bingc (inheritance)
kolla-ansible部署openstack yoga版本
Security problems in wireless networks and modern solutions