SHARE
TWEET

Untitled

a guest Dec 10th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  Convertire qualsiasi roba a 32 bit in array di interi a 8 bit    
  2. def convert32to8(x):
  3.     xint=np.uint32(x)
  4.     eightarray=[np.uint8(i) for i in xint.tobytes()]
  5.     return(eightarray)
  6.  
  7.  
  8. #Scrivere su file binario qualsiasi array a 32 bit
  9. with open('test.bin', 'wb') as fout:
  10.     for i in floatarray:
  11.         fout.write(struct.pack('>I', np.uint32(i)))
  12.        
  13. #Scrivere su file binario qualsiasi array di uint8
  14. with open('test.bin', 'wb') as fout:
  15.     for i in intarray:
  16.         fout.write(struct.pack('>B', i))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top