Print an integer array as hexadecimal numbers

后端 未结 7 490
南方客
南方客 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:29

    Just throwing in my two cents you could do this pretty simply using list comprehension if it's always a 2d array like that

    a = [[1,2],[3,4]]
    print [map(hex, l) for l in a]
    

    which gives you [['0x1', '0x2'], ['0x3', '0x4']]

提交回复
热议问题