我有下面的代码,在python2.7中它正是我想要的工作方式。它接受regs中的一系列整数值,并将每个值转换为其等效字符。例如,21365==>;0x5375 amd将导致“Su”。你知道吗
RegString = ""
for i in range(length):
if regs[start+i]!=0:
print (" Regs is ", regs[start+1], " Hex is ", hex(regs[start+i]), " Striped is ", str(format(regs[start+i],'x') ))
RegString = RegString + str(format(regs[start+i],'x').decode('hex'))
但是在python3中,decode('hex')会抛出一个错误。现在,我看了很多关于这个问题的帖子,但是还不能将这些解决方案应用到我的问题中,也就是修改上面的代码以在python3中工作。你知道吗
下面是我尝试运行这段代码时的输出:
Regs is 20341 Hex is 0x4f75 Striped is 4f75
Traceback (most recent call last): File "v3Test.py", line 23, in Get_Regester_String RegString = RegString + str(format(regs[start+i],'x').decode('hex'))
AttributeError: 'str' object has no attribute 'decode'
有人能给我指出正确的方向来修复上面失败的语句吗?这样它就可以在python3.7中工作了 ". 谢谢…RDK
对于python3,使用以下过程
相关问题 更多 >
编程相关推荐