Print an integer array as hexadecimal numbers

后端 未结 7 485
南方客
南方客 2020-12-11 00:43

I have an array created by using

array1 = np.array([[25,  160,   154, 233],
                   [61, 244,  198,  248],
                   [227, 226, 141, 72 ]         


        
7条回答
  •  北海茫月
    2020-12-11 01:31

    array1_hex = np.array([[hex(int(x)) for x in y] for y in array1])
    print array1_hex
    # => array([['0x19', '0xa0', '0x9a', '0xe9'],
    #           ['0x3d', '0xf4', '0xc6', '0xf8'],
    #           ['0xe3', '0xe2', '0x8d', '0x48'],
    #           ['0xbe', '0x2b', '0x2a', '0x8']], 
    #          dtype='|S4')
    

提交回复
热议问题