python unhexlify not working as expected

落花浮王杯 提交于 2019-12-08 02:48:21

Hint: What is the difference between these two lines:

data = binascii.hexlify(f.read(160))

binascii.unhexlify(data)

In Python, string objects are immutable. There is nothing you can call upon data that will cause the string that data names to change, because strings do not change. binascii.unhexlify instead returns a new string - which is why the first statement even works in the first place. If you wanted to .write the resulting new string, then that's what you should specify to happen in the code - either directly:

fo.write(binascii.unhexlify(data))

or by assigning it back to data first.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!