这是我目前。 有没有更好的方式来做到这一点?
import struct
def int32_to_uint32(i):
return struct.unpack_from("I", struct.pack("i", i))[0]
这是我目前。 有没有更好的方式来做到这一点?
import struct
def int32_to_uint32(i):
return struct.unpack_from("I", struct.pack("i", i))[0]
不知道是否是“更好”或不...
import ctypes
def int32_to_uint32(i):
return ctypes.c_uint32(i).value
使用numpy的例如:
import numpy
result = numpy.uint32( numpy.int32(myval) )
或甚至在阵列
arr = numpy.array(range(10))
result = numpy.uint32( numpy.int32(arr) )