下面的代码是python的,我要转换成java代码应该怎样写这个方法呢?请大神帮忙。。越快越好。非常感谢。 5
defstr_to_hex(self,data,size,spliter=':'):formatstr='%i'%sizeformatstr=formatstr+'B'l...
def str_to_hex(self, data, size, spliter=':'):
formatstr='%i' % size
formatstr = formatstr + 'B'
list=struct.unpack(formatstr,data )
str = ''
for i in range(0, size):
if (i==size-1 ):
tmp = '%02x' % (list[i])
else:
tmp = '%02x' + spliter
tmp = tmp % (list[i])
str = str+tmp
return str 展开
formatstr='%i' % size
formatstr = formatstr + 'B'
list=struct.unpack(formatstr,data )
str = ''
for i in range(0, size):
if (i==size-1 ):
tmp = '%02x' % (list[i])
else:
tmp = '%02x' + spliter
tmp = tmp % (list[i])
str = str+tmp
return str 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询