【问题标题】:how to get hex string from a HexBytes object?如何从 HexBytes 对象中获取十六进制字符串?
【发布时间】:2018-11-03 15:04:32
【问题描述】:
>>> from hexbytes import HexBytes
>>> ...
>>> hb
HexBytes('0x53b983fe73e16f6ed8178f6c0e0b91f23dc9dad4cb30d0831f178')

我有一个 HexBytes 对象 hb,我想得到 '0x53b983fe73e16f6ed8178f6c0e0b91f23dc9dad4cb30d0831f178' 字符串,我该怎么办?

【问题讨论】:

    标签: python web3


    【解决方案1】:

    您只需输入hb.hex() 就可以了

    【讨论】:

      【解决方案2】:

      从未使用过此模块,但这应该可以完成工作:

      hexdecimal = "".join(["{:02X}".format(b) for b in hb])
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-07-01
        • 1970-01-01
        • 2013-01-26
        • 2012-02-20
        • 2019-07-27
        • 2012-12-07
        • 2017-06-16
        • 2010-09-18
        相关资源
        最近更新 更多