Python 3.1.1 string to hex

前端 未结 9 918
野的像风
野的像风 2020-11-28 04:59

I am trying to use str.encode() but I get

>>> \"hello\".encode(hex)
Traceback (most recent call last):
  File \"\", line 1         


        
9条回答
  •  执笔经年
    2020-11-28 05:40

    The hex codec has been chucked in 3.x. Use binascii instead:

    >>> binascii.hexlify(b'hello')
    b'68656c6c6f'
    

提交回复
热议问题