1.两种方式:array.dtype=np.uint8 或是 array=array.astype( np.uint8 )

2.使用array=array.astype( np.uint8 )的时候必须astype后赋值,只是用array.astype( np.uint8 ) 是不会改变数据类型的,必须写成array=array.astype( np.uint8 )。

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐