📜  numpy.frombuffer()函数– Python

📅  最后修改于: 2022-05-13 01:54:28.690000             🧑  作者: Mango

numpy.frombuffer()函数– Python

numpy.frombuffer()函数将缓冲区解释为一维数组。

代码#1:

Python3
# Python program explaining
# numpy.frombuffer() function 
             
# importing numpy as geek 
import numpy as geek
   
gfg = geek.frombuffer(b'\x01\x02\x03', dtype = geek.uint8)
  
print (gfg)


Python3
# Python program explaining
# numpy.frombuffer() function 
             
# importing numpy as geek 
import numpy as geek
   
gfg = geek.frombuffer(b'\x01\x02\x03\x04\x05\x06\x07', dtype = geek.uint8, count = 5)
  
print (gfg)


输出 :

代码#2:

Python3

# Python program explaining
# numpy.frombuffer() function 
             
# importing numpy as geek 
import numpy as geek
   
gfg = geek.frombuffer(b'\x01\x02\x03\x04\x05\x06\x07', dtype = geek.uint8, count = 5)
  
print (gfg)

输出 :